From 561c313c4e110bccfd6ae41be737a4205305212d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9r=C3=A9nice=20Batut?= Date: Mon, 24 Jun 2024 10:36:31 +0200 Subject: [PATCH] Use new tutorial feedback API json --- bin/extract_gtn_tutorials.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/extract_gtn_tutorials.py b/bin/extract_gtn_tutorials.py index c94d70c2..4ceed72e 100644 --- a/bin/extract_gtn_tutorials.py +++ b/bin/extract_gtn_tutorials.py @@ -161,15 +161,16 @@ def get_feedback_per_tutorials() -> Dict: """ Get feedback from GTN API and group per tutorial """ - feedback = get_request_json("https://training.galaxyproject.org/training-material/api/feedback.json") + feedback = get_request_json("https://training.galaxyproject.org/training-material/api/feedback2.json") feedback_per_tuto = {} - for f in feedback: - tuto = f["tutorial"] - feedback_per_tuto.setdefault(tuto, {"number": 0, "mean note": 0}) - feedback_per_tuto[tuto]["number"] += 1 - feedback_per_tuto[tuto]["mean note"] += int(f["note"]) + for topic, tutorials in feedback.items(): + for tuto, feedback in tutorials.items(): + for f in feedback: + feedback_per_tuto.setdefault(tuto, {"number": 0, "mean rating": 0}) + feedback_per_tuto[tuto]["number"] += 1 + feedback_per_tuto[tuto]["mean rating"] += int(f["rating"]) for tuto in feedback_per_tuto: - feedback_per_tuto[tuto]["mean note"] /= feedback_per_tuto[tuto]["number"] + feedback_per_tuto[tuto]["mean rating"] /= feedback_per_tuto[tuto]["number"] return feedback_per_tuto