refactor: convert handleNotificationWhenNoSlots to service class with DI (#23055)
* refactor: convert handleNotificationWhenNoSlots to service class with DI - Convert standalone handleNotificationWhenNoSlots function to NoSlotsNotificationService class - Add INoSlotsNotificationService interface following existing patterns - Create NoSlotsNotification DI module and add to container - Add NO_SLOTS_NOTIFICATION_SERVICE tokens to DI_TOKENS - Inject service into AvailableSlotsService dependencies - Update AvailableSlotsService to use injected service instead of direct function call - Update all test cases to use service class pattern - Follows existing DI patterns used by other services like BusyTimesService and CheckBookingLimitsService Co-Authored-By: [email protected] <[email protected]> * refactor: move Prisma calls to repositories and create dedicated DI container - Add findOrganizationSettingsBySlug and findTeamSlugById methods to TeamRepository - Add findTeamAdminsByTeamId method to MembershipRepository - Create MembershipRepository DI module and tokens - Update NoSlotsNotificationService to inject TeamRepository, MembershipRepository, and Redis client - Create dedicated DI container for NoSlotsNotificationService - Update AvailableSlots DI container to include MembershipRepository - Replace direct Prisma and Redis calls with repository methods and injected client - Update tests to use DI container instead of direct service instantiation - Fix Redis interface import path Co-Authored-By: [email protected] <[email protected]> * chore: DI noSlotsNotification service * chore: bump library --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Morgan <[email protected]>
This commit is contained in:
19 files changed
+256
-122
No files matched your search
@@ -460,4 +460,28 @@ export class MembershipRepository {
|
||||
select: select ?? { userId: true },
|
||||
})) as unknown as Promise<MembershipDTOFromSelect<TSelect>[]>;
|
||||
}
|
||||
|
||||
async findTeamAdminsByTeamId({ teamId }: { teamId: number }) {
|
||||
return await this.prismaClient.membership.findMany({
|
||||
where: {
|
||||
team: {
|
||||
id: teamId,
|
||||
parentId: {
|
||||
not: null,
|
||||
},
|
||||
},
|
||||
role: {
|
||||
in: ["ADMIN", "OWNER"],
|
||||
},
|
||||
},
|
||||
select: {
|
||||
user: {
|
||||
select: {
|
||||
email: true,
|
||||
locale: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -350,4 +350,31 @@ export class TeamRepository {
|
||||
|
||||
return team?.parent;
|
||||
}
|
||||
|
||||
async findOrganizationSettingsBySlug({ slug }: { slug: string }) {
|
||||
return await this.prismaClient.team.findFirst({
|
||||
where: {
|
||||
slug,
|
||||
isOrganization: true,
|
||||
},
|
||||
select: {
|
||||
organizationSettings: {
|
||||
select: {
|
||||
adminGetsNoSlotsNotification: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findTeamSlugById({ id }: { id: number }) {
|
||||
return await this.prismaClient.team.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
select: {
|
||||
slug: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user