@@ -10,10 +10,16 @@ import type { Organization } from "~/models/organization.server";
10
10
import type { Project } from "~/models/project.server" ;
11
11
import { displayableEnvironment } from "~/models/runtimeEnvironment.server" ;
12
12
import type { User } from "~/models/user.server" ;
13
- import { filterOrphanedEnvironments , sortEnvironments } from "~/utils/environmentSort" ;
13
+ import {
14
+ filterOrphanedEnvironments ,
15
+ onlyDevEnvironments ,
16
+ exceptDevEnvironments ,
17
+ sortEnvironments ,
18
+ } from "~/utils/environmentSort" ;
14
19
import { logger } from "~/services/logger.server" ;
15
20
import { BasePresenter } from "./basePresenter.server" ;
16
21
import { TaskRunStatus } from "~/database-types" ;
22
+ import { CURRENT_DEPLOYMENT_LABEL } from "~/consts" ;
17
23
18
24
export type Task = {
19
25
slug : string ;
@@ -72,6 +78,9 @@ export class TaskListPresenter extends BasePresenter {
72
78
} ,
73
79
} ) ;
74
80
81
+ const devEnvironments = onlyDevEnvironments ( project . environments ) ;
82
+ const nonDevEnvironments = exceptDevEnvironments ( project . environments ) ;
83
+
75
84
const tasks = await this . _replica . $queryRaw <
76
85
{
77
86
id : string ;
@@ -83,12 +92,21 @@ export class TaskListPresenter extends BasePresenter {
83
92
triggerSource : TaskTriggerSource ;
84
93
} [ ]
85
94
> `
86
- WITH workers AS (
95
+ WITH non_dev_workers AS (
96
+ SELECT wd."workerId" AS id
97
+ FROM ${ sqlDatabaseSchema } ."WorkerDeploymentPromotion" wdp
98
+ INNER JOIN ${ sqlDatabaseSchema } ."WorkerDeployment" wd
99
+ ON wd.id = wdp."deploymentId"
100
+ WHERE wdp."environmentId" IN (${ Prisma . join ( nonDevEnvironments . map ( ( e ) => e . id ) ) } )
101
+ AND wdp."label" = ${ CURRENT_DEPLOYMENT_LABEL }
102
+ ),
103
+ workers AS (
87
104
SELECT DISTINCT ON ("runtimeEnvironmentId") id, "runtimeEnvironmentId", version
88
105
FROM ${ sqlDatabaseSchema } ."BackgroundWorker"
89
106
WHERE "runtimeEnvironmentId" IN (${ Prisma . join (
90
- filterOrphanedEnvironments ( project . environments ) . map ( ( e ) => e . id )
107
+ filterOrphanedEnvironments ( devEnvironments ) . map ( ( e ) => e . id )
91
108
) } )
109
+ OR id IN (SELECT id FROM non_dev_workers)
92
110
ORDER BY "runtimeEnvironmentId", "createdAt" DESC
93
111
)
94
112
SELECT tasks.id, slug, "filePath", "exportName", "triggerSource", tasks."runtimeEnvironmentId", tasks."createdAt"
0 commit comments