Files
calendar/packages/lib/server/repository/host.ts
T
MorganandGitHub ba8cca55e8 refactor: convert lucky user to service class (#23329)
* refactor: lucky user to service class with DI

* fix: unit test filterHostsByLeadThreshold.test.ts

* fixup! fix: unit test filterHostsByLeadThreshold.test.ts

* fix: get lucky user test missing mocks

* fix: get lucky user hosts not within interval

* chore: bump platform library

* chore: bump platform library

* chore: add DAILY_API_KEY to turborepo.json db seed

* chore: add DAILY_API_KEY to cache-db action

* fixup! chore: add DAILY_API_KEY to cache-db action

* chore: remove log in fixture

* chore: bump platform library

* chore: refactor test team-emails.e2e

* only failing test

* run all api v2 tests

* chore: bump platform library

* revert change to turbo.json and action in cache-db

* chore: use inPerson location in team-emails.e2e
2025-08-26 08:43:41 -03:00

41 lines
837 B
TypeScript

import type { PrismaClient } from "@calcom/prisma";
export class HostRepository {
constructor(private prismaClient: PrismaClient) {}
async updateHostsSchedule(userId: number, oldScheduleId: number, newScheduleId: number) {
return await this.prismaClient.host.updateMany({
where: {
userId,
scheduleId: oldScheduleId,
},
data: {
scheduleId: newScheduleId,
},
});
}
async findHostsCreatedInInterval({
eventTypeId,
userIds,
startDate,
}: {
eventTypeId: number;
userIds: number[];
startDate: Date;
}) {
return await this.prismaClient.host.findMany({
where: {
userId: {
in: userIds,
},
eventTypeId,
isFixed: false,
createdAt: {
gte: startDate,
},
},
});
}
}