stats: Fix bad query plan for remote counts.

We don't have an index on `(server_id, id)`, and in any case, we have
a stronger guarantee that `remote_id` is time-sorted, from the
construction of the analytics tables, than that the `id`s given these
entries when uploaded are time-sorted.
This commit is contained in:
Tim Abbott 2024-02-06 12:34:59 -08:00
parent b23d90ed62
commit 51542eb55e
1 changed files with 4 additions and 2 deletions

View File

@ -384,11 +384,13 @@ def get_chart_data(
_("No analytics data available. Please contact your server administrator.")
)
if start is None:
first = aggregate_table_remote.objects.filter(server=server).first()
first = (
aggregate_table_remote.objects.filter(server=server).order_by("remote_id").first()
)
assert first is not None
start = first.end_time
if end is None:
last = aggregate_table_remote.objects.filter(server=server).last()
last = aggregate_table_remote.objects.filter(server=server).order_by("remote_id").last()
assert last is not None
end = last.end_time
else: