Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 5 additions & 18 deletions apps/webapp/app/presenters/v3/BatchListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { timeFilters } from "~/components/runs/v3/SharedFilters";
export type BatchListOptions = {
userId?: string;
projectId: string;
environmentId: string;
//filters
friendlyId?: string;
statuses?: BatchTaskRunStatus[];
environments?: string[];
period?: string;
from?: number;
to?: number;
Expand All @@ -34,7 +34,7 @@ export class BatchListPresenter extends BasePresenter {
projectId,
friendlyId,
statuses,
environments,
environmentId,
period,
from,
to,
Expand Down Expand Up @@ -81,16 +81,6 @@ export class BatchListPresenter extends BasePresenter {
},
});

let environmentIds = project.environments.map((e) => e.id);
if (environments && environments.length > 0) {
//if environments are passed in, we only include them if they're in the project
environmentIds = environments.filter((e) => project.environments.some((pe) => pe.id === e));
}

if (environmentIds.length === 0) {
throw new Error("No matching environments found for the project");
}

const periodMs = time.period ? parse(time.period) : undefined;

//get the batches
Expand Down Expand Up @@ -120,8 +110,8 @@ export class BatchListPresenter extends BasePresenter {
FROM
${sqlDatabaseSchema}."BatchTaskRun" b
WHERE
-- environments
b."runtimeEnvironmentId" IN (${Prisma.join(environmentIds)})
-- environment
b."runtimeEnvironmentId" = ${environmentId}
-- cursor
${
cursor
Expand Down Expand Up @@ -186,9 +176,7 @@ WHERE
if (!hasAnyBatches) {
const firstBatch = await this._replica.batchTaskRun.findFirst({
where: {
runtimeEnvironmentId: {
in: environmentIds,
},
runtimeEnvironmentId: environmentId,
},
});

Expand Down Expand Up @@ -233,7 +221,6 @@ WHERE
filters: {
friendlyId,
statuses: statuses || [],
environments: environments || [],
},
hasFilters,
hasAnyBatches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const s = {
cursor: url.searchParams.get("cursor") ?? undefined,
direction: url.searchParams.get("direction") ?? undefined,
environments: [environment.id],
statuses: url.searchParams.getAll("statuses"),
period: url.searchParams.get("period") ?? undefined,
from: url.searchParams.get("from") ?? undefined,
Expand All @@ -93,6 +92,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
projectId: project.id,
...filters,
friendlyId: filters.id,
environmentId: environment.id,
});

return typedjson(list);
Expand Down