fix(metrics): convert PostgreSQL COUNT bigint to number
Some checks are pending
CI / lint + typecheck + tests (push) Waiting to run
CI / docker build + push (push) Blocked by required conditions

PostgreSQL COUNT() returns bigint type which Drizzle returns as a string.
This caused prom-client Gauge.set() to reject the value with error:
"TypeError: Value is not a valid number: 0"

Explicitly convert to Number to ensure prometheus metric accepts the value.

Related: BARAAA-64 - DB migrations and connection fixes

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Paperclip FoundingEngineer 2026-05-02 20:35:04 +00:00
parent cb374c0630
commit 3f3d6203b1

View file

@ -17,7 +17,7 @@ async function collectRoomsActiveMetric(pool: Pool): Promise<void> {
.select({ count: sql<number>`count(distinct ${roomMembers.roomId})` }) .select({ count: sql<number>`count(distinct ${roomMembers.roomId})` })
.from(roomMembers); .from(roomMembers);
const count = result[0]?.count || 0; const count = Number(result[0]?.count) || 0;
roomsActiveGauge.set(count); roomsActiveGauge.set(count);
const duration = (performance.now() - startTime) / 1000; const duration = (performance.now() - startTime) / 1000;