Skip to content

Commit

Permalink
fix: SJIP-768 adjust genomes and transcriptomes values (#136)
Browse files Browse the repository at this point in the history
* fix: SJIP-768 adjust genomes and transcriptomes values
  • Loading branch information
aperron-ferlab authored Apr 11, 2024
1 parent 2542ab8 commit e826c56
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions src/endpoints/statistics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,43 +105,57 @@ export const fetchVariantStats = async (client: Client): Promise<number> => {
};

export const fetchGenomesStats = async (client: Client): Promise<number> => {
const { body } = await client.search({
const { body } = await client.count({
index: esFileIndex,
body: {
size: 0,
query: {
bool: {
must: [
{
nested: {
path: 'sequencing_experiment',
query: {
term: {
'sequencing_experiment.experiment_strategy': 'WGS',
},
},
term: {
file_format: 'cram',
},
},
{
term: {
file_format: 'cram',
bool: {
should: [
{
nested: {
path: 'sequencing_experiment',
query: {
term: {
'sequencing_experiment.experiment_strategy':
'Whole Genome Sequencing',
},
},
},
},
{
nested: {
path: 'sequencing_experiment',
query: {
term: {
'sequencing_experiment.experiment_strategy': 'WGS',
},
},
},
},
],
},
},
],
},
},
aggs: { types_count: { value_count: { field: 'file_format' } } },
},
});

return body?.aggregations?.types_count.value;
return body?.count;
};

export const fetchTranscriptomesStats = async (client: Client): Promise<number> => {
const { body } = await client.search({
const { body } = await client.count({
index: esFileIndex,
body: {
size: 0,
query: {
bool: {
must: [
Expand All @@ -155,31 +169,22 @@ export const fetchTranscriptomesStats = async (client: Client): Promise<number>
},
},
},
],
should: [
{
term: {
file_format: 'cram',
},
},
{
term: {
file_format: 'fastq',
},
},
{
term: {
file_format: 'bam',
bool: {
should: [
{ term: { file_format: 'cram' } },
{ term: { file_format: 'fastq' } },
{ term: { file_format: 'bam' } },
],
},
},
],
},
},
aggs: { types_count: { value_count: { field: 'file_format' } } },
},
});

return body?.aggregations?.types_count.value;
return body?.count;
};

export const getStatistics = async (): Promise<Statistics> => {
Expand Down

0 comments on commit e826c56

Please sign in to comment.