Coder Social home page Coder Social logo

Data Array 구현 about dgu2020_covid_front HOT 5 CLOSED

hayunyun avatar hayunyun commented on June 21, 2024
Data Array 구현

from dgu2020_covid_front.

Comments (5)

SausageTaste avatar SausageTaste commented on June 21, 2024

존재하는 데이터의 구조만 바꿔달라는 요청인 것 같네요.
그런데 타입스크립트로 그냥 구현 하면 되는 거 아닌가요?
함수 하나만 만들면 될 것 같은데.

데이터를 저런 형식으로 반환하게끔 Django에 새로운 method를 만드는 것은 어려운 건 아닙니다만.
괜히 유지보수 하는 코드 늘어나는 것도 부담이고, 저 큰 데이터를 서버에서 한번 더 처리해야 하는 것도 부담이라서요.

from dgu2020_covid_front.

SausageTaste avatar SausageTaste commented on June 21, 2024

그리고 index 필드는 필요없습니다
for (const i in a_list) {} 이렇게 하면 저 i에는 element가 아니라 index 번호가 할당됩니다.

const a_list = ["a", "b", "c"];
for ( const i in a_list ) {
    console.log(i);
}

이 코드의 결과물은

a
b
c

가 아니라

0
1
2

가 됩니다.

from dgu2020_covid_front.

hayunyun avatar hayunyun commented on June 21, 2024

네 타입스크립트에서 구현하려는거예요! 함수를 짜고 있는데, 잘 나오지 않아서 issue에 올린 겁니다 ㅠㅠ index는 저도 굳이 넣어도 될 것 같진 않는데, 한 array에 같이 들어가는게 표를 짜기 더 좋아서 언급해두었습니다.

from dgu2020_covid_front.

SausageTaste avatar SausageTaste commented on June 21, 2024
function modify_data_struct(src: any) {
    const result = [];

    for (const acc_id in src) {
        result.push({
            acc_id: acc_id,
            simil_identity: src["acc_id"]["simil_identity"],
            simil_bit_score: src["acc_id"]["simil_bit_score"],
        });
    }

    return result;
}

이런 식으로 하면 안 됩니까?

from dgu2020_covid_front.

hayunyun avatar hayunyun commented on June 21, 2024

헐 해결된것같습니다!

        const lists = this.state.acc_id_list
        const seq_list = [];

        for (const acc_id in lists) {
            seq_list.push({
                acc_id: acc_id,
                simil_identity: lists[acc_id][cst.KEY_SIMILARITY_IDENTITY],
                simil_bit_score: lists[acc_id][cst.KEY_SIMILARITY_BIT_SCORE],
            });
        }

함수 말고, 말씀해주신 형식에서 아주 살짝 변형했습니다!
저번에 작성해주신 table for문이랑 비슷해서 저도 비슷하게 시도는 계속 해 봤던것 같은데...ㅎㅎ머쓱하네요
감사합니다. 덕분에 오늘 내로 완성할 수 있을 것 같습니다 :)

from dgu2020_covid_front.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.