Skip to content

Fetch User's Upcoming Interested/Attending Events #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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