Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SJIP-768 adjust genomes and transcriptomes values #136

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading