Skip to content

Commit

Permalink
add query shared feedbacks per month (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
yasmineDoghri6 authored May 13, 2024
1 parent 7e41aed commit ef955d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions usage-analytics/create-analytics/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ def create_analytics_tables(*_):
# This query answer the question "how many feedbacks are from externes each day/month"
execute_query("externe_feedbacks_per_day.sql", "feedzback_usage", "externe_feedbacks_per_day")
execute_query("externe_feedbacks_per_month.sql", "feedzback_usage", "externe_feedbacks_per_month")
# This query answer the question "how many feedbacks are shared with managers each month"
execute_query("shared_feedbacks_per_month.sql", "feedzback_usage", "shared_feedbacks_per_month")
return 'OK'
14 changes: 14 additions & 0 deletions usage-analytics/create-analytics/shared_feedbacks_per_month.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WITH shared_feedbacks AS (
SELECT DATE_TRUNC(TIMESTAMP_MILLIS(CAST(JSON_EXTRACT_SCALAR(DATA, "$.createdAt") AS INT)), MONTH) AS month,
JSON_EXTRACT_SCALAR(DATA, "$.status") AS status,
JSON_EXTRACT_SCALAR(DATA, "$.shared") AS shared,
FROM firestore_export.feedback_raw_latest
WHERE JSON_EXTRACT_SCALAR(DATA, "$.status") = "done"
)
SELECT count(*) as nb_feedbacks, month,
CASE
WHEN shared ="true" THEN "shared feedback"
WHEN shared="false" THEN "No shared feedback"
END AS shared_category
FROM shared_feedbacks
group by month, shared_category

0 comments on commit ef955d6

Please sign in to comment.