diff --git a/api/src/compute/generic_pipeline.ts b/api/src/compute/generic_pipeline.ts index 603229e02..3e291d29c 100644 --- a/api/src/compute/generic_pipeline.ts +++ b/api/src/compute/generic_pipeline.ts @@ -23,7 +23,6 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { const match: any = { survey, - [key]: { $nin: [null, '', [], {}] }, ...generateFiltersQuery(filters) } @@ -39,16 +38,28 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { // { $count: 'questionRespondents' }, { $unwind: { - path: `$${key}` + path: `$${key}`, + preserveNullAndEmptyArrays: true + } + }, + { + $set: { + [`${key}`]: { $cond: [ { $not: [`$${key}`] }, "no_answer", `$${key}` ] } } }, ...(facetPath ? [ - { - $unwind: { - path: `$${facetPath}` - } - } + { + $unwind: { + path: `$${facetPath}`, + preserveNullAndEmptyArrays: true + } + }, + { + $set: { + [`${facetPath}`]: { $cond: [ { $not: [`$${facetPath}`] }, "no_answer", `$${facetPath}` ] } + } + } ] : []), { diff --git a/api/src/data/keys.yml b/api/src/data/keys.yml index a1d14bcff..649b9ec4d 100644 --- a/api/src/data/keys.yml +++ b/api/src/data/keys.yml @@ -47,6 +47,7 @@ gender: - non_binary - not_listed + race_ethnicity: # - biracial - black_african @@ -106,14 +107,14 @@ feature: - heard - used -happiness: +happiness: - 0 - 1 - 2 - 3 - 4 -opinions: +opinions: - 0 - 1 - 2 @@ -132,12 +133,12 @@ graphql_experience: - range_3_5 - range_6_10 -code_generation_type: +code_generation_type: - code_first - schema_first - database_first -css_js_balance: +css_js_balance: - 0 - 1 - 2