Skip to content

Commit

Permalink
fix: SJIP-812 replace ethnicity with race in statistic route
Browse files Browse the repository at this point in the history
  • Loading branch information
aperron-ferlab committed Apr 24, 2024
1 parent 1dfee83 commit 38e49f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ describe('Express app (without Arranger)', () => {
variants: 1312312,
genomes: 13575,
transcriptomes: 5454,
sex: {
male: 4387,
female: 4302,
unknown: 4,
other: 3,
},
downSyndromeStatus: {
T21: 7266,
D21: 1430,
},
race: {
White: 7029,
'Black or African American': 618,
Expand All @@ -107,16 +117,6 @@ describe('Express app (without Arranger)', () => {
'Native Hawaiian or Other Pacific Islander': 8,
'not available': 3,
},
downSyndromeStatus: {
T21: 7266,
D21: 1430,
},
sex: {
male: 4387,
female: 4302,
unknown: 4,
other: 3,
},
diagnosis: [
{
mondo_id: 'speech disorder (MONDO:0004730)',
Expand Down
14 changes: 7 additions & 7 deletions src/endpoints/statistics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ export const fetchDemographicsStats = async (client: Client): Promise<Record<str
const response = await client.msearch({
body: [
{ index: esParticipantIndex },
{ size: 0, aggs: { race: { terms: { field: 'race', size: 20 } } } },
{ size: 0, aggs: { sex: { terms: { field: 'sex', size: 10 } } } },
{ index: esParticipantIndex },
{ size: 0, aggs: { down_syndrome_status: { terms: { field: 'down_syndrome_status', size: 10 } } } },
{ index: esParticipantIndex },
{ size: 0, aggs: { sex: { terms: { field: 'sex', size: 20 } } } },
{ size: 0, aggs: { race: { terms: { field: 'race', size: 20 } } } },
],
});

const race = response.body.responses[0].aggregations.race.buckets.reduce((acc, curr) => {
const sex = response.body.responses[0].aggregations.sex.buckets.reduce((acc, curr) => {
acc[curr.key] = curr.doc_count;
return acc;
}, {});
Expand All @@ -251,12 +251,12 @@ export const fetchDemographicsStats = async (client: Client): Promise<Record<str
},
{},
);
const sex = response.body.responses[2].aggregations.sex.buckets.reduce((acc, curr) => {
const race = response.body.responses[2].aggregations.race.buckets.reduce((acc, curr) => {
acc[curr.key] = curr.doc_count;
return acc;
}, {});

return [race, downSyndromeStatus, sex];
return [sex, downSyndromeStatus, race];
};

export const fetchTopDiagnosis = async (client: Client): Promise<Diagnosis[]> => {
Expand Down Expand Up @@ -316,9 +316,9 @@ export const getStatistics = async (): Promise<Statistics> => {
variants: results[6],
genomes: results[7],
transcriptomes: results[8],
race: results[9][0],
sex: results[9][0],
downSyndromeStatus: results[9][1],
sex: results[9][2],
race: results[9][2],
diagnosis,
};
};
Expand Down

0 comments on commit 38e49f3

Please sign in to comment.