diff --git a/usage-analytics/create-analytics/feedbackers_giver_receiver_repartition.sql b/usage-analytics/create-analytics/feedbackers_giver_receiver_repartition.sql new file mode 100644 index 00000000..a44ba26e --- /dev/null +++ b/usage-analytics/create-analytics/feedbackers_giver_receiver_repartition.sql @@ -0,0 +1,11 @@ +WITH feedbacks AS ( + SELECT + DATE_TRUNC(TIMESTAMP_MILLIS(CAST(JSON_EXTRACT_SCALAR(DATA, "$.createdAt") AS INT)), DAY) AS day, + JSON_EXTRACT_SCALAR(DATA, "$.giverEmail") AS giverEmail, + JSON_EXTRACT_SCALAR(DATA, "$.receiverEmail") AS receiverEmail + + FROM firestore_export.feedback_raw_latest +) +SELECT DISTINCT * +FROM feedbacks +WHERE JSON_EXTRACT_SCALAR(DATA, "$.status") = "done" \ No newline at end of file diff --git a/usage-analytics/create-analytics/main.py b/usage-analytics/create-analytics/main.py index 0f4613ad..64acff06 100644 --- a/usage-analytics/create-analytics/main.py +++ b/usage-analytics/create-analytics/main.py @@ -67,4 +67,6 @@ def create_analytics_tables(*_): 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") + # This query answers the question: "What is the number of givers and the number of receivers" + execute_query("feedbackers_giver_receiver_repartition.sql", "feedzback_usage", "feedbackers_giver_receiver_repartition") return 'OK'