Skip to content

Commit 3b71995

Browse files
committed
Added projectId back in to task queries (indexes)
1 parent 68317d6 commit 3b71995

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class TaskListPresenter extends BasePresenter {
4343
select: {
4444
id: true,
4545
type: true,
46+
projectId: true,
4647
},
4748
where: {
4849
slug: environmentSlug,
@@ -88,23 +89,26 @@ export class TaskListPresenter extends BasePresenter {
8889
//then get the activity for each task
8990
const activity = this.#getActivity(
9091
tasks.map((t) => t.slug),
92+
environment.projectId,
9193
environment.id
9294
);
9395

9496
const runningStats = this.#getRunningStats(
9597
tasks.map((t) => t.slug),
98+
environment.projectId,
9699
environment.id
97100
);
98101

99102
const durations = this.#getAverageDurations(
100103
tasks.map((t) => t.slug),
104+
environment.projectId,
101105
environment.id
102106
);
103107

104108
return { tasks, environment, activity, runningStats, durations };
105109
}
106110

107-
async #getActivity(tasks: string[], environmentId: string) {
111+
async #getActivity(tasks: string[], projectId: string, environmentId: string) {
108112
if (tasks.length === 0) {
109113
return {};
110114
}
@@ -126,6 +130,7 @@ export class TaskListPresenter extends BasePresenter {
126130
${sqlDatabaseSchema}."TaskRun" as tr
127131
WHERE
128132
tr."taskIdentifier" IN (${Prisma.join(tasks)})
133+
AND tr."projectId" = ${projectId}
129134
AND tr."runtimeEnvironmentId" = ${environmentId}
130135
AND tr."createdAt" >= (current_date - interval '6 days')
131136
GROUP BY
@@ -179,7 +184,7 @@ export class TaskListPresenter extends BasePresenter {
179184
}, {} as Record<string, ({ day: string } & Record<TaskRunStatusType, number>)[]>);
180185
}
181186

182-
async #getRunningStats(tasks: string[], environmentId: string) {
187+
async #getRunningStats(tasks: string[], projectId: string, environmentId: string) {
183188
if (tasks.length === 0) {
184189
return {};
185190
}
@@ -199,6 +204,7 @@ export class TaskListPresenter extends BasePresenter {
199204
${sqlDatabaseSchema}."TaskRun" as tr
200205
WHERE
201206
tr."taskIdentifier" IN (${Prisma.join(tasks)})
207+
AND tr."projectId" = ${projectId}
202208
AND tr."runtimeEnvironmentId" = ${environmentId}
203209
AND tr."status" = ANY(ARRAY[${Prisma.join([
204210
...QUEUED_STATUSES,
@@ -239,7 +245,7 @@ export class TaskListPresenter extends BasePresenter {
239245
return result;
240246
}
241247

242-
async #getAverageDurations(tasks: string[], environmentId: string) {
248+
async #getAverageDurations(tasks: string[], projectId: string, environmentId: string) {
243249
if (tasks.length === 0) {
244250
return {};
245251
}
@@ -257,6 +263,7 @@ export class TaskListPresenter extends BasePresenter {
257263
${sqlDatabaseSchema}."TaskRun" as tr
258264
WHERE
259265
tr."taskIdentifier" IN (${Prisma.join(tasks)})
266+
AND tr."projectId" = ${projectId}
260267
AND tr."runtimeEnvironmentId" = ${environmentId}
261268
AND tr."createdAt" >= (current_date - interval '6 days')
262269
AND tr."status" IN ('COMPLETED_SUCCESSFULLY', 'COMPLETED_WITH_ERRORS')

0 commit comments

Comments
 (0)