@@ -6,10 +6,8 @@ import {
66import { $replica } from "~/db.server" ;
77import { clickhouseFactory } from "~/services/clickhouse/clickhouseFactoryInstance.server" ;
88import {
9- type AverageDurations ,
109 ClickHouseEnvironmentMetricsRepository ,
1110 type CurrentRunningStats ,
12- type DailyTaskActivity ,
1311} from "~/services/environmentMetricsRepository.server" ;
1412import { singleton } from "~/utils/singleton" ;
1513import { findCurrentWorkerFromEnvironment } from "~/v3/models/workerDeployment.server" ;
@@ -21,8 +19,6 @@ export type TaskListItem = {
2119 triggerSource : TaskTriggerSource ;
2220} ;
2321
24- export type TaskActivity = DailyTaskActivity [ string ] ;
25-
2622export class TaskListPresenter {
2723 constructor ( private readonly _replica : PrismaClientOrTransaction ) { }
2824
@@ -55,9 +51,7 @@ export class TaskListPresenter {
5551 if ( ! currentWorker ) {
5652 return {
5753 tasks : [ ] ,
58- activity : Promise . resolve ( { } as DailyTaskActivity ) ,
5954 runningStats : Promise . resolve ( { } as CurrentRunningStats ) ,
60- durations : Promise . resolve ( { } as AverageDurations ) ,
6155 } ;
6256 }
6357
@@ -89,16 +83,10 @@ export class TaskListPresenter {
8983 clickhouse,
9084 } ) ;
9185
92- // IMPORTANT: Don't await these, we want to return the promises
93- // so we can defer the loading of the data
94- const activity = environmentMetricsRepository . getDailyTaskActivity ( {
95- organizationId,
96- projectId,
97- environmentId,
98- days : 6 , // This actually means 7 days, because we want to show the current day too
99- tasks : slugs ,
100- } ) ;
101-
86+ // IMPORTANT: Don't await this, we want to return the promise
87+ // so we can defer the loading of the data. The caller is responsible for
88+ // consuming it — an unconsumed promise here would become an unhandled
89+ // rejection if the underlying query fails.
10290 const runningStats = environmentMetricsRepository . getCurrentRunningStats ( {
10391 organizationId,
10492 projectId,
@@ -107,15 +95,7 @@ export class TaskListPresenter {
10795 tasks : slugs ,
10896 } ) ;
10997
110- const durations = environmentMetricsRepository . getAverageDurations ( {
111- organizationId,
112- projectId,
113- environmentId,
114- days : 6 ,
115- tasks : slugs ,
116- } ) ;
117-
118- return { tasks, activity, runningStats, durations } ;
98+ return { tasks, runningStats } ;
11999 }
120100}
121101
0 commit comments