Skip to content

Commit e837a1b

Browse files
Fix Devin Review bugs: postgres event repository fallback and error presenter clients
Co-Authored-By: Matt Aitken <matt@mattaitken.com>
1 parent 8fa3153 commit e837a1b

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

  • apps/webapp/app
    • routes
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors._index
    • v3/eventRepository

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint/route.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
242242
const directionRaw = url.searchParams.get("direction") ?? undefined;
243243
const direction = directionRaw ? DirectionSchema.parse(directionRaw) : undefined;
244244

245-
const clickhouseClient = await clickhouseFactory.getClickhouseForOrganization(
246-
environment.organizationId,
247-
"logs"
248-
);
245+
const [logsClickhouseClient, clickhouseClient] = await Promise.all([
246+
clickhouseFactory.getClickhouseForOrganization(environment.organizationId, "logs"),
247+
clickhouseFactory.getClickhouseForOrganization(environment.organizationId, "standard"),
248+
]);
249249

250-
const presenter = new ErrorGroupPresenter($replica, clickhouseClient, clickhouseClient);
250+
const presenter = new ErrorGroupPresenter($replica, logsClickhouseClient, clickhouseClient);
251251

252252
const detailPromise = presenter
253253
.call(project.organizationId, environment.id, {

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors._index/route.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
124124
const plan = await getCurrentPlan(project.organizationId);
125125
const retentionLimitDays = plan?.v3Subscription?.plan?.limits.logRetentionDays.number ?? 30;
126126

127-
const queryClickhouse = await clickhouseFactory.getClickhouseForOrganization(
127+
const logsClickhouseClient = await clickhouseFactory.getClickhouseForOrganization(
128128
project.organizationId,
129-
"query"
129+
"logs"
130130
);
131-
const presenter = new ErrorsListPresenter($replica, queryClickhouse);
131+
const presenter = new ErrorsListPresenter($replica, logsClickhouseClient);
132132

133133
const listPromise = presenter
134134
.call(project.organizationId, environment.id, {

apps/webapp/app/v3/eventRepository/index.server.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ export async function getConfiguredEventRepository(
5757
(organization.featureFlags as Record<string, unknown> | null) ?? undefined
5858
);
5959

60-
const { repository: resolvedRepository } =
61-
await clickhouseFactory.getEventRepositoryForOrganization(taskEventStore, organizationId);
62-
6360
if (taskEventStore === EVENT_STORE_TYPES.CLICKHOUSE_V2) {
61+
const { repository: resolvedRepository } =
62+
await clickhouseFactory.getEventRepositoryForOrganization(taskEventStore, organizationId);
6463
return { repository: resolvedRepository, store: EVENT_STORE_TYPES.CLICKHOUSE_V2 };
6564
}
6665

6766
if (taskEventStore === EVENT_STORE_TYPES.CLICKHOUSE) {
67+
const { repository: resolvedRepository } =
68+
await clickhouseFactory.getEventRepositoryForOrganization(taskEventStore, organizationId);
6869
return { repository: resolvedRepository, store: EVENT_STORE_TYPES.CLICKHOUSE };
6970
}
7071

@@ -104,6 +105,15 @@ export async function getV3EventRepository(
104105
parentStore: string | undefined
105106
): Promise<{ repository: IEventRepository; store: string }> {
106107
if (typeof parentStore === "string") {
108+
// Support legacy Postgres store for self-hosters and runs persisted with a
109+
// non-ClickHouse store — fall back to the Prisma-based event repository.
110+
if (
111+
parentStore !== EVENT_STORE_TYPES.CLICKHOUSE &&
112+
parentStore !== EVENT_STORE_TYPES.CLICKHOUSE_V2
113+
) {
114+
return { repository: eventRepository, store: parentStore };
115+
}
116+
107117
const { repository: resolvedRepository } =
108118
await clickhouseFactory.getEventRepositoryForOrganization(parentStore, organizationId);
109119
return { repository: resolvedRepository, store: parentStore };

0 commit comments

Comments
 (0)