Skip to content

Commit

Permalink
feat: add contactReachability_count & contactSatisfaction_count in ob…
Browse files Browse the repository at this point in the history
…servatoire stats metadata
  • Loading branch information
ClementNumericite committed Nov 30, 2024
1 parent fc71398 commit bc28536
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ const ProductCard = ({
satisfaction_count: 0,
comprehension_count: 0,
contact_count: 0,
contactReachability_count: 0,
contactSatisfaction_count: 0,
autonomy_count: 0
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const ObservatoireStats = ({
satisfaction_count: 0,
comprehension_count: 0,
contact_count: 0,
contactReachability_count: 0,
contactSatisfaction_count: 0,
autonomy_count: 0
}
}
Expand Down
12 changes: 8 additions & 4 deletions webapp-backoffice/src/server/routers/answer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,15 +1139,17 @@ export const answerRouter = router({
const { count: comprehension_count, average: comprehension_average } =
calculateBucketsAverage(comprehensionBuckets, comprehensionMarks);

const contactReachability_count = contactReachabilityBucket.reduce(
(sum, sb) => sum + (sb.doc_count || 0),
0
);

const contactReachability_average =
(contactReachabilityBucket.reduce((sum, sb) => {
const [, answer_text] = sb.key.split('#');
return sum + ((answer_text === 'Oui' && sb.doc_count) || 0);
}, 0) /
contactReachabilityBucket.reduce(
(sum, sb) => sum + (sb.doc_count || 0),
0
)) *
contactReachability_count) *
10;

const contactSatisfaction_count = contactSatisfactionBucket.reduce(
Expand Down Expand Up @@ -1209,6 +1211,8 @@ export const answerRouter = router({
satisfaction_count,
comprehension_count,
contact_count,
contactReachability_count,
contactSatisfaction_count,
autonomy_count
};

Expand Down

0 comments on commit bc28536

Please sign in to comment.