Skip to content

Commit de2996d

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

File tree

3 files changed

+21
-11
lines changed
  • apps/webapp/app
    • routes
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint
      • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors._index
    • v3/eventRepository

3 files changed

+21
-11
lines changed

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
@@ -241,12 +241,12 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
241241
const directionRaw = url.searchParams.get("direction") ?? undefined;
242242
const direction = directionRaw ? DirectionSchema.parse(directionRaw) : undefined;
243243

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

249-
const presenter = new ErrorGroupPresenter($replica, clickhouseClient, clickhouseClient);
249+
const presenter = new ErrorGroupPresenter($replica, logsClickhouseClient, clickhouseClient);
250250

251251
const detailPromise = presenter
252252
.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
@@ -123,11 +123,11 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
123123
const plan = await getCurrentPlan(project.organizationId);
124124
const retentionLimitDays = plan?.v3Subscription?.plan?.limits.logRetentionDays.number ?? 30;
125125

126-
const queryClickhouse = await clickhouseFactory.getClickhouseForOrganization(
126+
const logsClickhouseClient = await clickhouseFactory.getClickhouseForOrganization(
127127
project.organizationId,
128-
"query"
128+
"logs"
129129
);
130-
const presenter = new ErrorsListPresenter($replica, queryClickhouse);
130+
const presenter = new ErrorsListPresenter($replica, logsClickhouseClient);
131131

132132
const listPromise = presenter
133133
.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)