fix: replace max(uuid) with array_agg for preseem sync logs

- PostgreSQL's max() function doesn't work on UUID types
- Use array_agg to get first ID from grouped results instead
- Matches pattern already used for status field
- Fixes crash on /activity page when preseem sync logs exist
This commit is contained in:
Graham McIntire 2026-03-06 11:10:22 -06:00
parent bf7004c770
commit 2ba5a3fd7b
No known key found for this signature in database

View file

@ -301,7 +301,7 @@ defmodule Towerops.ActivityFeed do
from(sl in SyncLog,
where: sl.organization_id == ^org_id,
select: %{
id: max(sl.id),
id: fragment("(array_agg(? ORDER BY ? DESC))[1]", sl.id, sl.inserted_at),
timestamp: fragment("date_trunc('minute', ?)", sl.inserted_at),
status: fragment("(array_agg(? ORDER BY ? DESC))[1]", sl.status, sl.inserted_at),
records_synced: sum(sl.records_synced),