From aed5224a709bf006bbfa1a5e6640e6aa28e4e27e Mon Sep 17 00:00:00 2001 From: Rikki Guy Date: Fri, 27 Feb 2026 14:56:12 +0000 Subject: [PATCH] monitoring: Show only the latest dataset in snapshot API endpoint The dataset snapshot API currently lists *all* datasets ever recorded, but given a new dataset is create every day, the output of this endpoint will grow forever. This endpoint is currently only used by the Monitoring sheet to determine if it needs to update itsself, so it's important to keep the size of the output small. This does not affect the contents of db_dataset, so 360 internal reporting will still have access to all historical data. This endpoint can still show past dates' headline stats by passing the data parameter to the endpoint. --- datastore/api/monitoring/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datastore/api/monitoring/api.py b/datastore/api/monitoring/api.py index 1a8a6ae..2533a36 100644 --- a/datastore/api/monitoring/api.py +++ b/datastore/api/monitoring/api.py @@ -60,6 +60,10 @@ class DatasetMetricsSnapshotAPIView(SnapshotAPIView): renderer_classes = tuple(api_settings.DEFAULT_RENDERER_CLASSES) + (CSVRenderer,) serializer_class = DatasetMetricsRecordSerializer + def get_queryset(self): + # Show headline stats for the most recent dataset + return super().get_queryset().order_by("-timestamp")[0:1] + metrics_record_model = DatasetMetricsRecord