Skip to content

Commit

Permalink
feat: improve performance of modify guest
Browse files Browse the repository at this point in the history
  - fixed telegram, officehours isn't updated in event guest
  • Loading branch information
navneethkrish committed Oct 17, 2024
1 parent b0f7aa6 commit 451733c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions apps/web-api/src/pl-events/pl-event-guests.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -151,16 +151,16 @@ 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
}
},
member: {
select: {
name: true,
image: true,
image: { select: { url: true } },
telegramHandler: isUserLoggedIn ? true : false,
preferences: true,
officeHours: isUserLoggedIn ? true : false,
Expand All @@ -170,7 +170,7 @@ export class PLEventGuestsService {
select:{
uid: true,
name: true,
logo: true
logo: { select: { url: true } }
}
}
}
Expand All @@ -197,7 +197,7 @@ export class PLEventGuestsService {
select:{
uid: true,
name: true,
logo: true
logo: { select: { url: true } }
}
},
createdAt: true,
Expand All @@ -206,7 +206,7 @@ export class PLEventGuestsService {
}
});
this.restrictTelegramBasedOnMemberPreference(result, isUserLoggedIn);
this.restrictOfficeHours(result, isUserLoggedIn);
// this.restrictOfficeHours(result, isUserLoggedIn);
return result;
}
catch(err) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web-api/src/pl-events/pl-event-locations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
14 changes: 7 additions & 7 deletions apps/web-api/src/pl-events/pl-events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -82,7 +82,7 @@ export class PLEventsService {
select:{
uid: true,
name: true,
logo: true
logo: { select: { url: true } }
}
}
}
Expand All @@ -109,7 +109,7 @@ export class PLEventsService {
select:{
uid: true,
name: true,
logo: true
logo: { select: { url: true } }
}
}
}
Expand All @@ -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) {
Expand Down

0 comments on commit 451733c

Please sign in to comment.