fix: Refines data transformation in heatmap view

Simplifies data processing by removing unnecessary value extraction.
Prepares for future enhancement to return color as value with count as tooltip.
This commit is contained in:
Kumi 2024-11-17 20:05:40 +01:00
parent 841c5e08de
commit 8ffdeddf4a
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -566,11 +566,11 @@ class MoodCountHeatmapJSONView(LoginRequiredMixin, View):
user=request.user, timestamp__gte=mindate, timestamp__lte=maxdate
)
.values("timestamp__date")
.annotate(value=Count("id"))
)
data = [{"date": d["timestamp__date"].strftime("%Y-%m-%d"), "value": d["value"]} for d in data]
# TODO: Should eventually change this so that it returns a *color* as a value and the count as a tooltip
data = [{"date": d.timestamp.strftime("%Y-%m-%d"), "value": d.value} for d in data]
res.write(json.dumps(data))