Skip to content

Conversation

@jimmywin656
Copy link
Contributor

Implemented a GET route that returns all of a user's upcoming events only if they marked them as "Interested" or "Attending". To implement the route, I created a new controller function called getUserEvents and brought in the userIdValidator to validate the userId.

@jimmywin656 jimmywin656 requested a review from lxkedinh as a code owner April 19, 2024 00:19
Comment on lines +210 to +228
const userEvents = await prisma.events.findMany({
where: {
eventAttendees: {
some: {
userId: userId,
status: { in: ["Interested", "Attending"] },
},
},
startDate: { gte: currentDate },
},
select: {
eventId: true,
startDate: true,
eventAttendees: {
select: { status: true },
where: { userId: userId },
},
},
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will be displayed as a list of event info cards for the user, let's sort them by ascending start date for convenience.

Comment on lines +411 to +412
router.get(
"/:userId/events",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking into it a bit more, I think it makes more sense to move this to the user router instead so it becomes GET /users/:userId/events. This follows REST API convention more since we're interested in the events (a subcollection) of a particular user with userId in the users collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants