Skip to content

Commit 6ac165a

Browse files
committed
Added versions filter to the fingerprint page
1 parent 1eb2afa commit 6ac165a

File tree

3 files changed

+30
-6
lines changed
  • apps/webapp/app

3 files changed

+30
-6
lines changed

apps/webapp/app/presenters/v3/ErrorGroupPresenter.server.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type ErrorGroupOptions = {
2727
userId?: string;
2828
projectId: string;
2929
fingerprint: string;
30+
versions?: string[];
3031
runsPageSize?: number;
3132
period?: string;
3233
from?: number;
@@ -39,6 +40,7 @@ export const ErrorGroupOptionsSchema = z.object({
3940
userId: z.string().optional(),
4041
projectId: z.string(),
4142
fingerprint: z.string(),
43+
versions: z.array(z.string()).optional(),
4244
runsPageSize: z.number().int().positive().max(1000).optional(),
4345
period: z.string().optional(),
4446
from: z.number().int().nonnegative().optional(),
@@ -89,6 +91,7 @@ export class ErrorGroupPresenter extends BasePresenter {
8991
userId,
9092
projectId,
9193
fingerprint,
94+
versions,
9295
runsPageSize = DEFAULT_RUNS_PAGE_SIZE,
9396
period,
9497
from,
@@ -117,6 +120,7 @@ export class ErrorGroupPresenter extends BasePresenter {
117120
userId,
118121
projectId,
119122
fingerprint,
123+
versions,
120124
pageSize: runsPageSize,
121125
from: time.from.getTime(),
122126
to: time.to.getTime(),
@@ -149,7 +153,8 @@ export class ErrorGroupPresenter extends BasePresenter {
149153
environmentId: string,
150154
fingerprint: string,
151155
from: Date,
152-
to: Date
156+
to: Date,
157+
versions?: string[]
153158
): Promise<{
154159
data: Array<{ date: Date; count: number }>;
155160
}> {
@@ -169,6 +174,10 @@ export class ErrorGroupPresenter extends BasePresenter {
169174
toTimeMs: to.getTime(),
170175
});
171176

177+
if (versions && versions.length > 0) {
178+
queryBuilder.where("task_version IN {versions: Array(String)}", { versions });
179+
}
180+
172181
queryBuilder.groupBy("error_fingerprint, bucket_epoch");
173182
queryBuilder.orderBy("bucket_epoch ASC");
174183

@@ -275,6 +284,7 @@ export class ErrorGroupPresenter extends BasePresenter {
275284
userId?: string;
276285
projectId: string;
277286
fingerprint: string;
287+
versions?: string[];
278288
pageSize: number;
279289
from?: number;
280290
to?: number;
@@ -289,6 +299,7 @@ export class ErrorGroupPresenter extends BasePresenter {
289299
projectId: options.projectId,
290300
rootOnly: false,
291301
errorId: ErrorId.toFriendlyId(options.fingerprint),
302+
versions: options.versions,
292303
pageSize: options.pageSize,
293304
from: options.from,
294305
to: options.to,

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { RunsIcon } from "~/assets/icons/RunsIcon";
4646
import { TaskRunListSearchFilters } from "~/components/runs/v3/RunFilters";
4747
import { useSearchParams } from "~/hooks/useSearchParam";
4848
import { CopyableText } from "~/components/primitives/CopyableText";
49+
import { LogsVersionFilter } from "~/components/logs/LogsVersionFilter";
4950

5051
export const meta: MetaFunction<typeof loader> = ({ data }) => {
5152
return [
@@ -82,6 +83,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
8283
const toStr = url.searchParams.get("to");
8384
const from = fromStr ? parseInt(fromStr, 10) : undefined;
8485
const to = toStr ? parseInt(toStr, 10) : undefined;
86+
const versions = url.searchParams.getAll("versions").filter((v) => v.length > 0);
8587
const cursor = url.searchParams.get("cursor") ?? undefined;
8688
const directionRaw = url.searchParams.get("direction") ?? undefined;
8789
const direction = directionRaw ? DirectionSchema.parse(directionRaw) : undefined;
@@ -93,6 +95,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
9395
userId,
9496
projectId: project.id,
9597
fingerprint,
98+
versions: versions.length > 0 ? versions : undefined,
9699
period,
97100
from,
98101
to,
@@ -115,7 +118,8 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
115118
environment.id,
116119
fingerprint,
117120
time.from,
118-
time.to
121+
time.to,
122+
versions.length > 0 ? versions : undefined
119123
)
120124
.catch(() => ({ data: [] as ErrorGroupActivity }));
121125

@@ -149,6 +153,9 @@ export default function Page() {
149153
if (period) carry.set("period", period);
150154
if (from) carry.set("from", from);
151155
if (to) carry.set("to", to);
156+
for (const v of searchParams.getAll("versions")) {
157+
if (v) carry.append("versions", v);
158+
}
152159
const qs = carry.toString();
153160
return qs ? `${base}?${qs}` : base;
154161
}, [organizationSlug, projectParam, envParam, searchParams.toString()]);
@@ -232,7 +239,7 @@ function ErrorGroupDetail({
232239
envParam: string;
233240
fingerprint: string;
234241
}) {
235-
const { value } = useSearchParams();
242+
const { value, values } = useSearchParams();
236243
const organization = useOrganization();
237244
const project = useProject();
238245
const environment = useEnvironment();
@@ -252,11 +259,13 @@ function ErrorGroupDetail({
252259

253260
const fromValue = value("from") ?? undefined;
254261
const toValue = value("to") ?? undefined;
262+
const selectedVersions = values("versions").filter((v) => v !== "");
255263

256264
const filters: TaskRunListSearchFilters = {
257265
period: value("period") ?? undefined,
258266
from: fromValue ? parseInt(fromValue, 10) : undefined,
259267
to: toValue ? parseInt(toValue, 10) : undefined,
268+
versions: selectedVersions.length > 0 ? selectedVersions : undefined,
260269
rootOnly: false,
261270
errorId: ErrorId.toFriendlyId(fingerprint),
262271
};
@@ -318,8 +327,9 @@ function ErrorGroupDetail({
318327

319328
{/* Activity chart */}
320329
<div className="flex flex-col gap-3 overflow-hidden border-b border-grid-bright px-4 py-3">
321-
<div className="flex items-center">
330+
<div className="flex items-center gap-1">
322331
<TimeFilter defaultPeriod="7d" labelName="Occurred" />
332+
<LogsVersionFilter />
323333
</div>
324334

325335
<Suspense fallback={<ActivityChartBlankState />}>
@@ -369,10 +379,10 @@ function ErrorGroupDetail({
369379
{runList ? (
370380
<TaskRunsTable
371381
total={runList.runs.length}
372-
hasFilters={false}
382+
hasFilters={selectedVersions.length > 0}
373383
filters={{
374384
tasks: [],
375-
versions: [],
385+
versions: selectedVersions,
376386
statuses: [],
377387
from: undefined,
378388
to: undefined,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ function ErrorGroupRow({
379379
if (period) carry.set("period", period);
380380
if (from) carry.set("from", from);
381381
if (to) carry.set("to", to);
382+
for (const v of searchParams.getAll("versions")) {
383+
if (v) carry.append("versions", v);
384+
}
382385
const qs = carry.toString();
383386
return qs ? `${base}?${qs}` : base;
384387
}, [organizationSlug, projectParam, envParam, errorGroup.fingerprint, searchParams.toString()]);

0 commit comments

Comments
 (0)