Skip to content

Commit 6ccd84f

Browse files
committed
Switch to read replica: v2 run list presenter
1 parent 82f9de3 commit 6ccd84f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

apps/webapp/app/presenters/RunListPresenter.server.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "~/components/runs/RunStatuses";
88
import { PrismaClient, prisma } from "~/db.server";
99
import { getUsername } from "~/utils/username";
10+
import { BasePresenter } from "./v3/basePresenter.server";
1011

1112
type RunListOptions = {
1213
userId: string;
@@ -27,12 +28,8 @@ const DEFAULT_PAGE_SIZE = 20;
2728

2829
export type RunList = Awaited<ReturnType<RunListPresenter["call"]>>;
2930

30-
export class RunListPresenter {
31-
#prismaClient: PrismaClient;
32-
33-
constructor(prismaClient: PrismaClient = prisma) {
34-
this.#prismaClient = prismaClient;
35-
}
31+
export class RunListPresenter extends BasePresenter {
32+
3633

3734
public async call({
3835
userId,
@@ -53,7 +50,7 @@ export class RunListPresenter {
5350
const directionMultiplier = direction === "forward" ? 1 : -1;
5451

5552
// Find the organization that the user is a member of
56-
const organization = await this.#prismaClient.organization.findFirstOrThrow({
53+
const organization = await this._replica.organization.findFirstOrThrow({
5754
select: {
5855
id: true,
5956
},
@@ -64,7 +61,7 @@ export class RunListPresenter {
6461
});
6562

6663
// Find the project scoped to the organization
67-
const project = await this.#prismaClient.project.findFirstOrThrow({
64+
const project = await this._replica.project.findFirstOrThrow({
6865
select: {
6966
id: true,
7067
},
@@ -75,7 +72,7 @@ export class RunListPresenter {
7572
});
7673

7774
const job = jobSlug
78-
? await this.#prismaClient.job.findFirstOrThrow({
75+
? await this._replica.job.findFirstOrThrow({
7976
where: {
8077
slug: jobSlug,
8178
projectId: project.id,
@@ -84,10 +81,10 @@ export class RunListPresenter {
8481
: undefined;
8582

8683
const event = eventId
87-
? await this.#prismaClient.eventRecord.findUnique({ where: { id: eventId } })
84+
? await this._replica.eventRecord.findUnique({ where: { id: eventId } })
8885
: undefined;
8986

90-
const runs = await this.#prismaClient.jobRun.findMany({
87+
const runs = await this._replica.jobRun.findMany({
9188
select: {
9289
id: true,
9390
number: true,

0 commit comments

Comments
 (0)