Skip to content

Commit

Permalink
Add option to include attendees in GET events (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasozh authored Apr 28, 2024
1 parent a39846b commit e70c9f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion backend/src/events/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ const getEvents = async (
pagination: {
after: string;
limit: string;
},
include: {
attendees: boolean;
}
) => {
/* SORTING */
Expand Down Expand Up @@ -116,7 +119,7 @@ const getEvents = async (
/* FILTERING */

let whereDict: { [key: string]: any } = {};
let includeDict: { [key: string]: any } = {};
let includeDict: { [key: string]: any } = include;

// Handles GET /events?date=upcoming and GET /events?date=past
// TODO: Investigate creating events that occur in a few minutes into the future
Expand Down
8 changes: 7 additions & 1 deletion backend/src/events/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ eventRouter.get("/", useAuth, async (req: Request, res: Response) => {
limit: req.query.limit as string,
};

attempt(res, 200, () => eventController.getEvents(filter, sort, pagination));
const include = {
attendees: req.query.include === "attendees" ? true : false,
};

attempt(res, 200, () =>
eventController.getEvents(filter, sort, pagination, include)
);
});

eventRouter.get("/upcoming", useAuth, async (req: Request, res: Response) => {
Expand Down

0 comments on commit e70c9f3

Please sign in to comment.