fix: convert binary UUID to text in activity feed sync query

Fixes Jason.EncodeError when rendering activity feed. PostgreSQL
array_agg was returning binary UUID which caused invalid UTF-8 bytes
when interpolated into 'sy-#{row.id}' string. Cast to ::text in the
fragment to ensure string representation.
This commit is contained in:
Graham McIntire 2026-03-06 17:33:34 -06:00
parent 053ad8b373
commit 180bfa6de2
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: fragment("(array_agg(? ORDER BY ? DESC))[1]", sl.id, sl.inserted_at),
id: fragment("(array_agg(?::text 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),