Repository navigation
feat: rework event roles tables - #965
Conversation
CodeSee Review Map:Review in an interactive map View more CodeSee Maps Legend |
|
Hey, @gikf I'm just merging main into this (in part to understand how things are supposed to fit together) |
| if (oldUserRole) { | ||
| await prisma.event_users.delete({ |
There was a problem hiding this comment.
I don't think this logic works with the new db schema. Before, if the rsvp existed, then rsvpEvent should cancel that rsvp and allow someone on the waitlist to join.
Now an event_user entry will exist if a user has some relationship to a given event (they've been invited, they've canceled, etc) so, the logic should be (crudely):
if (userIsGoingToEvent) {
cancelRsvp();
moveUserOffWaitlist();
} else {
confirmUserRsvp();
}
There was a problem hiding this comment.
Yeah, there's some ambiguousness when somebody presses cancel by their rsvp/request. After merging main I'll change it to not remove from event_user, but assign another rsvp.
|
@gikf I'm struggling a little with this merge, to be honest. There's a lot of moving parts and I'm pretty sure I'm going to break things. If you're feeling brave, could you take a look? Once we've got this in I'll try and clean up the resolvers a bit. They're a bit too sprawling to wrap my brain around at the moment. |
|
@ojeytonwilliams I've merged |
|
I know how tough that was, so nice one! I'll give it a proper look next week and see if I can find anything amiss. |
ojeytonwilliams
left a comment
There was a problem hiding this comment.
Hi @gikf this looks really solid. Thanks again for fixing all those conflicts.
I only spotted one thing that looked like a bug, the rest are nitpicks:
| notifying Boolean @default(false) | ||
| event events @relation(fields: [event_id], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
| user users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
| rsvp rsvp @relation(fields: [rsvp_id], references: [id], onDelete: Cascade, onUpdate: NoAction) |
There was a problem hiding this comment.
Shouldn't this reference event_users? The rsvp table just stores the types of rsvps, now.
Since this didn't trip up any tests, it would be good to add some coverage for the reminders.
There was a problem hiding this comment.
I don't know honestly, but not necessarily. It definitely can have such reference added. I found simply replacing old rsvps with event_users a bit redundant. Other than rsvp -> name (due to it being in the reminder text placeholder), there isn't anything else in event_user needed, that's not already available from events or users relations.
Therefore it was for me either leaving relations with events, users and adding missing new rsvp, or replacing all three with event_users. Does this make sense? What do you think?
As for tests - there were merge conflicts triggered! 😛
There was a problem hiding this comment.
Okay, so reminders can only exist if there's an event_user because if someone has no relationship to an event, they definitely don't want a reminder. To me, it makes most sense to go with your idea of replacing all three with a single event_user reference.
I've been messing with this locally, do you mind if I push a commit?
There was a problem hiding this comment.
Not at all, go ahead. 👍
But make sure you have the latest changes, I was correcting merge conflicts earlier today.
There was a problem hiding this comment.
Thanks for the warning, I'll double-check!
Co-authored-by: Oliver Eyton-Williams <[email protected]>
Co-authored-by: Oliver Eyton-Williams <[email protected]>
…o feat/event-roles-tables
| interface RsvpInvitationUser { | ||
| first_name: string; | ||
| email: string; | ||
| } | ||
| interface RsvpInvitationEvent { | ||
| name: string; | ||
| start_at: Date; | ||
| ends_at: Date; | ||
| description: string; | ||
| venue: Venue | null; | ||
| } |
There was a problem hiding this comment.
| interface RsvpInvitationUser { | |
| first_name: string; | |
| email: string; | |
| } | |
| interface RsvpInvitationEvent { | |
| name: string; | |
| start_at: Date; | |
| ends_at: Date; | |
| description: string; | |
| venue: Venue | null; | |
| } |
Rather than recreating these types, we can pull them out of prisma, I'll add a suggestion below.
| EventUser, | ||
| EventWithRelations, | ||
| EventWithChapter, | ||
| Venue, |
There was a problem hiding this comment.
| Venue, | |
| User, |
See below
| const sendRsvpInvitation = async ( | ||
| user: RsvpInvitationUser, | ||
| event: RsvpInvitationEvent, |
There was a problem hiding this comment.
| const sendRsvpInvitation = async ( | |
| user: RsvpInvitationUser, | |
| event: RsvpInvitationEvent, | |
| const sendRsvpInvitation = async ( | |
| user: User, | |
| event: events & { venue: venues | null }, |
This also avoids mixing the GraphQL types (like Venue) with the Prisma return types. This doesn't matter a great deal, but it makes 100% clear where things are coming from.
| interface RsvpNotificationUser { | ||
| first_name: string; | ||
| last_name: string; | ||
| } | ||
| interface RsvpNotificationEvent { | ||
| name: string; | ||
| event_users: Pick<EventUser, 'user' | 'event_role'>[]; | ||
| } |
There was a problem hiding this comment.
| interface RsvpNotificationUser { | |
| first_name: string; | |
| last_name: string; | |
| } | |
| interface RsvpNotificationEvent { | |
| name: string; | |
| event_users: Pick<EventUser, 'user' | 'event_role'>[]; | |
| } | |
| type RsvpNotificationEvent = events & { | |
| event_users: { event_role: event_roles; user: users }[]; | |
| }; |
Same principle as above, but this is a little bigger, so it seemed better to create an alias.
| event_users: Pick<EventUser, 'user' | 'event_role'>[]; | ||
| } | ||
| const rsvpNotifyOrganizer = async ( | ||
| user: RsvpNotificationUser, |
There was a problem hiding this comment.
| user: RsvpNotificationUser, | |
| user: User, |
| interface EventRsvpName { | ||
| capacity: number; | ||
| event_users: Pick<EventUser, 'rsvp'>[]; | ||
| invite_only: boolean; | ||
| } |
There was a problem hiding this comment.
| interface EventRsvpName { | |
| capacity: number; | |
| event_users: Pick<EventUser, 'rsvp'>[]; | |
| invite_only: boolean; | |
| } | |
| type EventRsvpName = events & { event_users: (event_users & { rsvp: rsvp })[] }; |
Same principle again.
| notifying Boolean @default(false) | ||
| event events @relation(fields: [event_id], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
| user users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction) | ||
| rsvp rsvp @relation(fields: [rsvp_id], references: [id], onDelete: Cascade, onUpdate: NoAction) |
There was a problem hiding this comment.
Okay, so reminders can only exist if there's an event_user because if someone has no relationship to an event, they definitely don't want a reminder. To me, it makes most sense to go with your idea of replacing all three with a single event_user reference.
I've been messing with this locally, do you mind if I push a commit?
Also various minor refactors
|
@gikf all done. Let me know if you're happy with these last changes. If you are, we can finally get this in! |
|
I didn't find anything sticking out 👍 |
|
Great, thanks for checking. I'm very happy to finally get this in. |

Update README.md).mainbranch of Chapter.event_userrequires going as deep asevent_user->event_role->event_role_permissions->event_permission. This could be changed with makingevent_roleorevent_role_permissionsoptional in graphql type.rsvps, this might need some refining. I usednorsvp as a canceled rsvp. It is set in client when user cancels.