From e93daaf9ecef75823a92918d976be4fea3a6185b Mon Sep 17 00:00:00 2001 From: Will Li Date: Sat, 28 Jun 2025 06:38:03 -0700 Subject: [PATCH] backfill fix, get most recent git URL to handle old ssh links (#150) * backfill fix, get most recent git URL to handle old ssh links * reduce the changes --- apps/web/src/actions/analytics/events.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/web/src/actions/analytics/events.ts b/apps/web/src/actions/analytics/events.ts index 84ededc4b6..ab48f09f60 100644 --- a/apps/web/src/actions/analytics/events.ts +++ b/apps/web/src/actions/analytics/events.ts @@ -278,7 +278,8 @@ export const getRepositoryUsage = async ({ query: ` SELECT repositoryName, - any(repositoryUrl) as repositoryUrl, + -- Get most recent timestamp to backfill old URL + argMax(repositoryUrl, timestamp) as repositoryUrl, SUM(CASE WHEN type = '${TelemetryEventName.TASK_CREATED}' THEN 1 ELSE 0 END) AS tasksStarted, SUM(CASE WHEN type = '${TelemetryEventName.TASK_COMPLETED}' THEN 1 ELSE 0 END) AS tasksCompleted, SUM(CASE WHEN type = '${TelemetryEventName.LLM_COMPLETION}' THEN ${tokenSumSql()} ELSE 0 END) AS tokens, @@ -484,7 +485,7 @@ export const getTasks = async ({ SUM(CASE WHEN e.type = 'LLM Completion' THEN COALESCE(e.cost, 0) ELSE 0 END) AS cost, MIN(e.timestamp) AS timestamp, any(fm.title) AS title, - any(e.repositoryUrl) AS repositoryUrl, + argMax(e.repositoryUrl, e.timestamp) AS repositoryUrl, any(e.repositoryName) AS repositoryName, any(e.defaultBranch) AS defaultBranch FROM events e