diff --git a/memberportal/api_metrics/tasks.py b/memberportal/api_metrics/tasks.py index 2f00c62e..a43a7ade 100644 --- a/memberportal/api_metrics/tasks.py +++ b/memberportal/api_metrics/tasks.py @@ -34,9 +34,7 @@ def calculate_metrics(): .annotate(total=Count("state")) .order_by("total") ) - profile_states_data = [ - f"{item['state']}: {item['total']}" for item in profile_states - ] + profile_states_data = [{item["state"]: item["total"]} for item in profile_states] Metric.objects.create( name=Metric.MetricName.MEMBER_COUNT_TOTAL, data=profile_states_data ).full_clean() @@ -50,8 +48,7 @@ def calculate_metrics(): .order_by("total") ) subscription_states_data = [ - f"{item['subscription_status']}: {item['total']}" - for item in subscription_states + {item["subscription_status"]: item["total"]} for item in subscription_states ] Metric.objects.create( name=Metric.MetricName.SUBSCRIPTION_COUNT_TOTAL, diff --git a/memberportal/api_metrics/views.py b/memberportal/api_metrics/views.py index 708052bc..bb1b24cf 100644 --- a/memberportal/api_metrics/views.py +++ b/memberportal/api_metrics/views.py @@ -43,7 +43,6 @@ def post(self, request): # get the latest metric for each type for name in Metric.MetricName.values: - print(name) metric = Metric.objects.filter(name=name).order_by("-creation_date").first() if metric: metrics.append(metric) @@ -60,7 +59,7 @@ def post(self, request): continue for state in metric.data: - print(f"Setting {metric.name} {state['state']} to {state['total']}") + print(f"Setting {metric.name}:" + state) prom_metric.labels(state=state["state"]).set(state["total"]) return Response()