Skip to content

Commit a22a8ba

Browse files
committed
update test presenter
1 parent a54ec4d commit a22a8ba

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

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

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { TaskTriggerSource } from "@trigger.dev/database";
2-
import { sqlDatabaseSchema, PrismaClient, prisma } from "~/db.server";
1+
import { PrismaClient, prisma } from "~/db.server";
32
import { TestSearchParams } from "~/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.test/route";
43
import { sortEnvironments } from "~/utils/environmentSort";
54
import { createSearchParams } from "~/utils/searchParams";
6-
import { getUsername } from "~/utils/username";
5+
import { findCurrentWorkerDeployment } from "~/v3/models/workerDeployment.server";
76

87
type TaskListOptions = {
98
userId: string;
@@ -85,31 +84,9 @@ export class TestPresenter {
8584
};
8685
}
8786

88-
//get all possible tasks
89-
const tasks = await this.#prismaClient.$queryRaw<
90-
{
91-
id: string;
92-
version: string;
93-
taskIdentifier: string;
94-
filePath: string;
95-
exportName: string;
96-
friendlyId: string;
97-
triggerSource: TaskTriggerSource;
98-
}[]
99-
>`WITH workers AS (
100-
SELECT
101-
bw.*,
102-
ROW_NUMBER() OVER(ORDER BY string_to_array(bw.version, '.')::int[] DESC) AS rn
103-
FROM
104-
${sqlDatabaseSchema}."BackgroundWorker" bw
105-
WHERE "runtimeEnvironmentId" = ${matchingEnvironment.id}
106-
),
107-
latest_workers AS (SELECT * FROM workers WHERE rn = 1)
108-
SELECT bwt.id, version, slug as "taskIdentifier", "filePath", "exportName", bwt."friendlyId", bwt."triggerSource"
109-
FROM latest_workers
110-
JOIN ${sqlDatabaseSchema}."BackgroundWorkerTask" bwt ON bwt."workerId" = latest_workers.id
111-
ORDER BY bwt."exportName" ASC;
112-
`;
87+
const currentDeployment = await findCurrentWorkerDeployment(matchingEnvironment.id);
88+
89+
const tasks = currentDeployment?.worker?.tasks ?? [];
11390

11491
return {
11592
hasSelectedEnvironment: true as const,
@@ -118,8 +95,7 @@ export class TestPresenter {
11895
tasks: tasks.map((task) => {
11996
return {
12097
id: task.id,
121-
version: task.version,
122-
taskIdentifier: task.taskIdentifier,
98+
taskIdentifier: task.slug,
12399
filePath: task.filePath,
124100
exportName: task.exportName,
125101
friendlyId: task.friendlyId,

0 commit comments

Comments
 (0)