1+ import { CURRENT_DEPLOYMENT_LABEL } from "@trigger.dev/core/v3/isomorphic" ;
12import {
23 Prisma ,
3- type TaskTriggerSource ,
4- type TaskRunStatus as TaskRunStatusType ,
5- type RuntimeEnvironment ,
64 type TaskRunStatus as DBTaskRunStatus ,
5+ type TaskRunStatus as TaskRunStatusType ,
6+ type TaskTriggerSource ,
77} from "@trigger.dev/database" ;
88import { QUEUED_STATUSES } from "~/components/runs/v3/TaskRunStatus" ;
9+ import { TaskRunStatus } from "~/database-types" ;
910import { sqlDatabaseSchema } from "~/db.server" ;
10- import type { Organization } from "~/models/organization.server" ;
11- import type { Project } from "~/models/project.server" ;
12- import type { User } from "~/models/user.server" ;
1311import { logger } from "~/services/logger.server" ;
1412import { BasePresenter } from "./basePresenter.server" ;
15- import { TaskRunStatus } from "~/database-types" ;
16- import { CURRENT_DEPLOYMENT_LABEL } from "@trigger.dev/core/v3/isomorphic" ;
1713
1814export type TaskListItem = {
1915 slug : string ;
@@ -27,34 +23,7 @@ type Return = Awaited<ReturnType<TaskListPresenter["call"]>>;
2723export type TaskActivity = Awaited < Return [ "activity" ] > [ string ] ;
2824
2925export class TaskListPresenter extends BasePresenter {
30- public async call ( {
31- userId,
32- projectSlug,
33- organizationSlug,
34- environmentSlug,
35- } : {
36- userId : User [ "id" ] ;
37- projectSlug : Project [ "slug" ] ;
38- organizationSlug : Organization [ "slug" ] ;
39- environmentSlug : RuntimeEnvironment [ "slug" ] ;
40- } ) {
41- const environment = await this . _replica . runtimeEnvironment . findFirstOrThrow ( {
42- select : {
43- id : true ,
44- type : true ,
45- projectId : true ,
46- } ,
47- where : {
48- slug : environmentSlug ,
49- project : {
50- slug : projectSlug ,
51- } ,
52- organization : {
53- slug : organizationSlug ,
54- } ,
55- } ,
56- } ) ;
57-
26+ public async call ( { environmentId, projectId } : { environmentId : string ; projectId : string } ) {
5827 const tasks = await this . _replica . $queryRaw <
5928 {
6029 id : string ;
@@ -69,13 +38,13 @@ export class TaskListPresenter extends BasePresenter {
6938 FROM ${ sqlDatabaseSchema } ."WorkerDeploymentPromotion" wdp
7039 INNER JOIN ${ sqlDatabaseSchema } ."WorkerDeployment" wd
7140 ON wd.id = wdp."deploymentId"
72- WHERE wdp."environmentId" = ${ environment . id }
41+ WHERE wdp."environmentId" = ${ environmentId }
7342 AND wdp."label" = ${ CURRENT_DEPLOYMENT_LABEL }
7443 ),
7544 workers AS (
7645 SELECT DISTINCT ON ("runtimeEnvironmentId") id, "runtimeEnvironmentId", version
7746 FROM ${ sqlDatabaseSchema } ."BackgroundWorker"
78- WHERE "runtimeEnvironmentId" = ${ environment . id }
47+ WHERE "runtimeEnvironmentId" = ${ environmentId }
7948 OR id IN (SELECT id FROM non_dev_workers)
8049 ORDER BY "runtimeEnvironmentId", "createdAt" DESC
8150 )
@@ -87,23 +56,23 @@ export class TaskListPresenter extends BasePresenter {
8756 //then get the activity for each task
8857 const activity = this . #getActivity(
8958 tasks . map ( ( t ) => t . slug ) ,
90- environment . projectId ,
91- environment . id
59+ projectId ,
60+ environmentId
9261 ) ;
9362
9463 const runningStats = this . #getRunningStats(
9564 tasks . map ( ( t ) => t . slug ) ,
96- environment . projectId ,
97- environment . id
65+ projectId ,
66+ environmentId
9867 ) ;
9968
10069 const durations = this . #getAverageDurations(
10170 tasks . map ( ( t ) => t . slug ) ,
102- environment . projectId ,
103- environment . id
71+ projectId ,
72+ environmentId
10473 ) ;
10574
106- return { tasks, environment , activity, runningStats, durations } ;
75+ return { tasks, activity, runningStats, durations } ;
10776 }
10877
10978 async #getActivity( tasks : string [ ] , projectId : string , environmentId : string ) {
0 commit comments