From 451733c7bb34e0d92c2b1c113062bd909081a187 Mon Sep 17 00:00:00 2001 From: Navaneethakrishnan Date: Tue, 15 Oct 2024 20:37:59 +0530 Subject: [PATCH] feat: improve performance of modify guest - fixed telegram, officehours isn't updated in event guest --- .../src/pl-events/pl-event-guests.service.ts | 22 +++++++++---------- .../pl-events/pl-event-locations.service.ts | 2 +- .../src/pl-events/pl-events.service.ts | 14 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/web-api/src/pl-events/pl-event-guests.service.ts b/apps/web-api/src/pl-events/pl-event-guests.service.ts index 8ceb10da9..27037741d 100644 --- a/apps/web-api/src/pl-events/pl-event-guests.service.ts +++ b/apps/web-api/src/pl-events/pl-event-guests.service.ts @@ -43,7 +43,7 @@ export class PLEventGuestsService { data.memberUid = isAdmin ? data.memberUid : member.uid; const guests = this.formatInputToEventGuests(data); const result = await (tx || this.prisma).pLEventGuest.createMany({ data: guests }); - await this.cacheService.reset(); + this.cacheService.reset(); return result; } catch(err) { this.handleErrors(err); @@ -151,8 +151,8 @@ export class PLEventGuestsService { description: true, startDate: true, endDate: true, - logo: true, - banner: true, + logo: { select: { url: true } }, + banner: { select: { url: true } }, resources: true, additionalInfo: true } @@ -160,7 +160,7 @@ export class PLEventGuestsService { member: { select: { name: true, - image: true, + image: { select: { url: true } }, telegramHandler: isUserLoggedIn ? true : false, preferences: true, officeHours: isUserLoggedIn ? true : false, @@ -170,7 +170,7 @@ export class PLEventGuestsService { select:{ uid: true, name: true, - logo: true + logo: { select: { url: true } } } } } @@ -197,7 +197,7 @@ export class PLEventGuestsService { select:{ uid: true, name: true, - logo: true + logo: { select: { url: true } } } }, createdAt: true, @@ -206,7 +206,7 @@ export class PLEventGuestsService { } }); this.restrictTelegramBasedOnMemberPreference(result, isUserLoggedIn); - this.restrictOfficeHours(result, isUserLoggedIn); + // this.restrictOfficeHours(result, isUserLoggedIn); return result; } catch(err) { @@ -287,10 +287,10 @@ export class PLEventGuestsService { restrictTelegramBasedOnMemberPreference(eventGuests, isUserLoggedIn: boolean) { if (isUserLoggedIn && eventGuests) { eventGuests = eventGuests.map((guest:any) => { - if (!guest.telegramId) { - delete guest.member.telegramHandler; - return guest; - } + // if (!guest.telegramId) { + // delete guest.member.telegramHandler; + // return guest; + // } if (!guest.member.preferences) { return guest; } diff --git a/apps/web-api/src/pl-events/pl-event-locations.service.ts b/apps/web-api/src/pl-events/pl-event-locations.service.ts index 09a5423bc..a65f8921e 100644 --- a/apps/web-api/src/pl-events/pl-event-locations.service.ts +++ b/apps/web-api/src/pl-events/pl-event-locations.service.ts @@ -136,7 +136,7 @@ export class PLEventLocationsService { events.forEach((event) => { const eventStartDateInZone = moment.utc(event.startDate).tz(timezone); const eventEndDateInZone = moment.utc(event.endDate).tz(timezone); - if (eventStartDateInZone.isBefore(currentDateTimeInZone)) { + if (eventEndDateInZone.isBefore(currentDateTimeInZone)) { pastEvents.push({ ...event, startDate: eventStartDateInZone.format(), diff --git a/apps/web-api/src/pl-events/pl-events.service.ts b/apps/web-api/src/pl-events/pl-events.service.ts index dbaaf3952..6d50e11c1 100644 --- a/apps/web-api/src/pl-events/pl-events.service.ts +++ b/apps/web-api/src/pl-events/pl-events.service.ts @@ -49,8 +49,8 @@ export class PLEventsService { const plEvent = await this.prisma.pLEvent.findUniqueOrThrow({ where: { slugURL: slug }, include: { - logo: true, - banner: true, + logo: { select: { url: true } }, + banner: { select: { url: true } }, eventGuests: { select: { uid: true, @@ -66,12 +66,12 @@ export class PLEventsService { officeHours: isUserLoggedIn ? true : false, event: { include: { - logo: true + logo: { select: { url: true } } } }, member: { select:{ - image: true, + image: { select: { url: true } }, name: true, preferences: true, telegramHandler: isUserLoggedIn ? true : false, @@ -82,7 +82,7 @@ export class PLEventsService { select:{ uid: true, name: true, - logo: true + logo: { select: { url: true } } } } } @@ -109,7 +109,7 @@ export class PLEventsService { select:{ uid: true, name: true, - logo: true + logo: { select: { url: true } } } } } @@ -119,7 +119,7 @@ export class PLEventsService { if (plEvent) { this.filterPrivateResources(plEvent, isUserLoggedIn); plEvent.eventGuests = this.eventGuestsService.restrictTelegramBasedOnMemberPreference(plEvent?.eventGuests, isUserLoggedIn); - plEvent.eventGuests = this.eventGuestsService.restrictOfficeHours(plEvent?.eventGuests, isUserLoggedIn); + // plEvent.eventGuests = this.eventGuestsService.restrictOfficeHours(plEvent?.eventGuests, isUserLoggedIn); } return plEvent; } catch(err) {