From 8e880a63859267b00062be9355c35768ff9ae947 Mon Sep 17 00:00:00 2001 From: Viktors Dobkevics Date: Thu, 29 Dec 2022 15:26:29 +0200 Subject: [PATCH 1/5] Added noAnswer key and updated generic_pipeline aggregation --- api/src/compute/generic_pipeline.ts | 15 ++++++++---- api/src/data/keys.yml | 38 +++++------------------------ 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/api/src/compute/generic_pipeline.ts b/api/src/compute/generic_pipeline.ts index 603229e02..4bdeaef9d 100644 --- a/api/src/compute/generic_pipeline.ts +++ b/api/src/compute/generic_pipeline.ts @@ -37,6 +37,11 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { $match: match }, // { $count: 'questionRespondents' }, + { + $set: { + [`${facetPath}`]: { $cond: [ { $not: [`$${facetPath}`] }, "noAnswer", `$${facetPath}` ] } + } + }, { $unwind: { path: `$${key}` @@ -44,11 +49,11 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { }, ...(facetPath ? [ - { - $unwind: { - path: `$${facetPath}` - } - } + // { + // $unwind: { + // path: `$${facetPath}` + // } + // } ] : []), { diff --git a/api/src/data/keys.yml b/api/src/data/keys.yml index 5eff8d33f..2d862cc6c 100644 --- a/api/src/data/keys.yml +++ b/api/src/data/keys.yml @@ -9,6 +9,7 @@ age: - range_more_than_65 years_of_experience: + - no_answer - range_less_than_1 - range_1_2 - range_2_5 @@ -60,33 +61,6 @@ race_ethnicity: - south_east_asian - not_listed -industry_sector: - - ecommerce - - news_media - - healthcare - - finance - - programming_tools - - socialmedia - - marketing_tools - - education - - real_estate - - government - - entertainment - - consulting - - travel - - insurance - - logistics - - energy - - telecommunications - - student - - hospitality - - cyber_security - - construction - - automotive - - agriculture - - transport - - manufacturing - tool: - would_use - would_not_use @@ -99,14 +73,14 @@ feature: - heard - used -happiness: +happiness: - 0 - 1 - 2 - 3 - 4 -opinions: +opinions: - 0 - 1 - 2 @@ -125,12 +99,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 @@ -139,4 +113,4 @@ css_js_balance: - 5 - 6 - 7 - - 8 \ No newline at end of file + - 8 From 79a4fefb92bf0396ff2971017f2f9a454030836f Mon Sep 17 00:00:00 2001 From: Viktors Dobkevics Date: Thu, 29 Dec 2022 15:36:33 +0200 Subject: [PATCH 2/5] Added missing industry_selectior keys --- api/src/data/keys.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/api/src/data/keys.yml b/api/src/data/keys.yml index 2d862cc6c..580bc5c28 100644 --- a/api/src/data/keys.yml +++ b/api/src/data/keys.yml @@ -48,6 +48,7 @@ gender: - non_binary - not_listed + race_ethnicity: # - biracial - black_african @@ -61,6 +62,33 @@ race_ethnicity: - south_east_asian - not_listed +industry_sector: + - ecommerce + - news_media + - healthcare + - finance + - programming_tools + - socialmedia + - marketing_tools + - education + - real_estate + - government + - entertainment + - consulting + - travel + - insurance + - logistics + - energy + - telecommunications + - student + - hospitality + - cyber_security + - construction + - automotive + - agriculture + - transport + - manufacturing + tool: - would_use - would_not_use From 8f2ef57a85ec1446f841e8d07c31233e65203903 Mon Sep 17 00:00:00 2001 From: Viktors Dobkevics Date: Wed, 18 Jan 2023 05:45:17 +0200 Subject: [PATCH 3/5] Added no_answer key to buckets, updated generic_pipeline.ts --- api/src/compute/generic_pipeline.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/api/src/compute/generic_pipeline.ts b/api/src/compute/generic_pipeline.ts index 4bdeaef9d..cefa2d1bd 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,21 +38,16 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { // { $count: 'questionRespondents' }, { $set: { - [`${facetPath}`]: { $cond: [ { $not: [`$${facetPath}`] }, "noAnswer", `$${facetPath}` ] } - } - }, - { - $unwind: { - path: `$${key}` + [`${key}`]: { $cond: [ { $not: [`$${key}`] }, "no_answer", `$${key}` ] } } }, ...(facetPath ? [ - // { - // $unwind: { - // path: `$${facetPath}` - // } - // } + { + $set: { + [`${facetPath}`]: { $cond: [ { $not: [`$${facetPath}`] }, "no_answer", `$${facetPath}` ] } + } + } ] : []), { From 42afe3dadec0216f6a6e9529cb6bb5a57a45823f Mon Sep 17 00:00:00 2001 From: Viktors Dobkevics Date: Wed, 18 Jan 2023 05:52:20 +0200 Subject: [PATCH 4/5] Removed no_answer key from keys.yml --- api/src/data/keys.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/data/keys.yml b/api/src/data/keys.yml index 580bc5c28..7fc667575 100644 --- a/api/src/data/keys.yml +++ b/api/src/data/keys.yml @@ -9,7 +9,6 @@ age: - range_more_than_65 years_of_experience: - - no_answer - range_less_than_1 - range_1_2 - range_2_5 From 28fdd214ca57149fa5e151afabcdc39a65dd862f Mon Sep 17 00:00:00 2001 From: Viktors Dobkevics Date: Wed, 18 Jan 2023 18:09:51 +0200 Subject: [PATCH 5/5] Added unwind with preserveNullAndEmptyArrays option to fix field with multi select option --- api/src/compute/generic_pipeline.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/src/compute/generic_pipeline.ts b/api/src/compute/generic_pipeline.ts index cefa2d1bd..3e291d29c 100644 --- a/api/src/compute/generic_pipeline.ts +++ b/api/src/compute/generic_pipeline.ts @@ -36,6 +36,12 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { $match: match }, // { $count: 'questionRespondents' }, + { + $unwind: { + path: `$${key}`, + preserveNullAndEmptyArrays: true + } + }, { $set: { [`${key}`]: { $cond: [ { $not: [`$${key}`] }, "no_answer", `$${key}` ] } @@ -43,6 +49,12 @@ export const getGenericPipeline = (pipelineProps: PipelineProps) => { }, ...(facetPath ? [ + { + $unwind: { + path: `$${facetPath}`, + preserveNullAndEmptyArrays: true + } + }, { $set: { [`${facetPath}`]: { $cond: [ { $not: [`$${facetPath}`] }, "no_answer", `$${facetPath}` ] }