Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions packages/api/src/routes/admin/analytics/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ export const platformAnalyticsRoutes = new Elysia({ prefix: '/platform' })
const [userGrowth, packGrowth, catalogGrowth] = await Promise.all([
db
.select({
date: sql<string>`date_trunc(${period}, ${users.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${users.createdAt})::date::text`,
count: count(),
})
.from(users)
.where(gte(users.createdAt, startDate))
.groupBy(sql`date_trunc(${period}, ${users.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${users.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${users.createdAt})`)
.orderBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${users.createdAt})`),
Comment on lines +52 to +53
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The groupBy call is missing the closing template-literal backtick/parenthesis, which will cause a TypeScript syntax error and prevent this route from compiling. Close the sql template literal and the groupBy(...) call before chaining .orderBy(...).

Copilot uses AI. Check for mistakes.
db
.select({
date: sql<string>`date_trunc(${period}, ${packs.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${packs.createdAt})::date::text`,
count: count(),
})
.from(packs)
.where(and(eq(packs.deleted, false), gte(packs.createdAt, startDate)))
.groupBy(sql`date_trunc(${period}, ${packs.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${packs.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${packs.createdAt})`)
.orderBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${packs.createdAt})`),
Comment on lines +61 to +62
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The groupBy call is not properly closed (missing closing backtick/)), which breaks the query builder chain and results in invalid TypeScript. Ensure groupBy(sql...) is fully closed before .orderBy(...).

Copilot uses AI. Check for mistakes.
db
.select({
date: sql<string>`date_trunc(${period}, ${catalogItems.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${catalogItems.createdAt})::date::text`,
count: count(),
})
.from(catalogItems)
.where(gte(catalogItems.createdAt, startDate))
.groupBy(sql`date_trunc(${period}, ${catalogItems.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${catalogItems.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${catalogItems.createdAt})`)
.orderBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${catalogItems.createdAt})`),
Comment on lines +70 to +71
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This groupBy call appears to be missing its closing backtick/parenthesis, which will make the file fail to parse/compile. Close the sql template literal and groupBy(...) invocation.

Copilot uses AI. Check for mistakes.
]);

const userMap = Object.fromEntries(userGrowth.map((r) => [r.date, r.count]));
Expand Down Expand Up @@ -113,16 +113,16 @@ export const platformAnalyticsRoutes = new Elysia({ prefix: '/platform' })
const [tripActivity, trailActivity, postActivity] = await Promise.all([
db
.select({
date: sql<string>`date_trunc(${period}, ${trips.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${trips.createdAt})::date::text`,
count: count(),
})
.from(trips)
.where(and(eq(trips.deleted, false), gte(trips.createdAt, startDate)))
.groupBy(sql`date_trunc(${period}, ${trips.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${trips.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${trips.createdAt})`)
.orderBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${trips.createdAt})`),
Comment on lines +121 to +122
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The groupBy invocation isn’t closed (missing closing backtick/)), so the subsequent .orderBy(...) is currently attached to an unterminated expression. Close groupBy(sql...) before chaining.

Copilot uses AI. Check for mistakes.
db
.select({
date: sql<string>`date_trunc(${period}, ${trailConditionReports.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${trailConditionReports.createdAt})::date::text`,
count: count(),
})
.from(trailConditionReports)
Expand All @@ -132,17 +132,19 @@ export const platformAnalyticsRoutes = new Elysia({ prefix: '/platform' })
gte(trailConditionReports.createdAt, startDate),
),
)
.groupBy(sql`date_trunc(${period}, ${trailConditionReports.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${trailConditionReports.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${trailConditionReports.createdAt})`)
.orderBy(
sql`date_trunc(${sql.raw(`'${period}'`)}, ${trailConditionReports.createdAt})`,
),
Comment on lines +135 to +138
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groupBy(sql...) is missing its closing backtick/parenthesis here, which will cause a syntax error. Close the sql template and the groupBy(...) call before the multi-line .orderBy(...).

Copilot uses AI. Check for mistakes.
db
.select({
date: sql<string>`date_trunc(${period}, ${posts.createdAt})::date::text`,
date: sql<string>`date_trunc(${sql.raw(`'${period}'`)}, ${posts.createdAt})::date::text`,
count: count(),
})
.from(posts)
.where(gte(posts.createdAt, startDate))
.groupBy(sql`date_trunc(${period}, ${posts.createdAt})`)
.orderBy(sql`date_trunc(${period}, ${posts.createdAt})`),
.groupBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${posts.createdAt})`)
.orderBy(sql`date_trunc(${sql.raw(`'${period}'`)}, ${posts.createdAt})`),
Comment on lines +146 to +147
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This groupBy call is missing its closing backtick/parenthesis, which breaks parsing/compilation. Close groupBy(sql...) before chaining .orderBy(...).

Copilot uses AI. Check for mistakes.
]);

const tripMap = Object.fromEntries(tripActivity.map((r) => [r.date, r.count]));
Expand Down
Loading