@@ -4,6 +4,7 @@ import { PrismaClient, prisma, sqlDatabaseSchema } from "~/db.server";
4
4
import { displayableEnvironment } from "~/models/runtimeEnvironment.server" ;
5
5
import { getUsername } from "~/utils/username" ;
6
6
import { calculateNextScheduledTimestamp } from "~/v3/utils/calculateNextSchedule.server" ;
7
+ import { BasePresenter } from "./basePresenter.server" ;
7
8
8
9
type ScheduleListOptions = {
9
10
projectId : string ;
@@ -34,12 +35,7 @@ export type ScheduleListItem = {
34
35
export type ScheduleList = Awaited < ReturnType < ScheduleListPresenter [ "call" ] > > ;
35
36
export type ScheduleListAppliedFilters = ScheduleList [ "filters" ] ;
36
37
37
- export class ScheduleListPresenter {
38
- #prismaClient: PrismaClient ;
39
-
40
- constructor ( prismaClient : PrismaClient = prisma ) {
41
- this . #prismaClient = prismaClient ;
42
- }
38
+ export class ScheduleListPresenter extends BasePresenter {
43
39
44
40
public async call ( {
45
41
userId,
@@ -54,7 +50,7 @@ export class ScheduleListPresenter {
54
50
tasks !== undefined || environments !== undefined || ( search !== undefined && search !== "" ) ;
55
51
56
52
// Find the project scoped to the organization
57
- const project = await this . #prismaClient . project . findFirstOrThrow ( {
53
+ const project = await this . _replica . project . findFirstOrThrow ( {
58
54
select : {
59
55
id : true ,
60
56
environments : {
@@ -82,7 +78,7 @@ export class ScheduleListPresenter {
82
78
} ) ;
83
79
84
80
//get all possible scheduled tasks
85
- const possibleTasks = await this . #prismaClient . backgroundWorkerTask . findMany ( {
81
+ const possibleTasks = await this . _replica . backgroundWorkerTask . findMany ( {
86
82
distinct : [ "slug" ] ,
87
83
where : {
88
84
projectId : project . id ,
@@ -93,7 +89,7 @@ export class ScheduleListPresenter {
93
89
//do this here to protect against SQL injection
94
90
search = search && search !== "" ? `%${ search } %` : undefined ;
95
91
96
- const totalCount = await this . #prismaClient . taskSchedule . count ( {
92
+ const totalCount = await this . _replica . taskSchedule . count ( {
97
93
where : {
98
94
projectId : project . id ,
99
95
taskIdentifier : tasks ? { in : tasks } : undefined ,
@@ -135,7 +131,7 @@ export class ScheduleListPresenter {
135
131
} ,
136
132
} ) ;
137
133
138
- const rawSchedules = await this . #prismaClient . taskSchedule . findMany ( {
134
+ const rawSchedules = await this . _replica . taskSchedule . findMany ( {
139
135
select : {
140
136
id : true ,
141
137
friendlyId : true ,
@@ -199,7 +195,7 @@ export class ScheduleListPresenter {
199
195
200
196
const latestRuns =
201
197
rawSchedules . length > 0
202
- ? await this . #prismaClient . $queryRaw < { scheduleId : string ; createdAt : Date } [ ] > `
198
+ ? await this . _replica . $queryRaw < { scheduleId : string ; createdAt : Date } [ ] > `
203
199
SELECT t."scheduleId", t."createdAt"
204
200
FROM (
205
201
SELECT "scheduleId", MAX("createdAt") as "LatestRun"
0 commit comments