Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aydan Pirani committed Sep 18, 2024
1 parent b425df7 commit e178f5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/services/checkin/checkin-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ checkinRouter.post(
RoleChecker([Role.Enum.ADMIN, Role.Enum.STAFF]),
async (req, res, next) => {
try {
const { eventId, userId } = EventValidator.parse(
req.body
);
const { eventId, userId } = EventValidator.parse(req.body);

try {
await checkInUserToEvent(eventId, userId);
Expand Down
11 changes: 3 additions & 8 deletions src/services/checkin/checkin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async function updateAttendeePriority(userId: string) {
);
}


async function updateAttendanceRecords(eventId: string, userId: string) {
await Promise.all([
Database.EVENTS_ATTENDANCE.findOneAndUpdate(
Expand Down Expand Up @@ -92,13 +91,10 @@ async function markUserAsCheckedIn(userId: string) {
);
}

export async function checkInUserToEvent(
eventId: string,
userId: string,
) {
export async function checkInUserToEvent(eventId: string, userId: string) {
await checkEventAndAttendeeExist(eventId, userId);
await checkForDuplicateAttendance(eventId, userId);

const event = await Database.EVENTS.findOne({ eventId });
if (!event) {
throw new Error("Event not found");
Expand All @@ -107,13 +103,12 @@ export async function checkInUserToEvent(
// check for checkin event, and for meals
if (event.eventType == EventType.Enum.CHECKIN) {
await markUserAsCheckedIn(userId);
} else if (event.eventType != EventType.Enum.MEALS){
} else if (event.eventType != EventType.Enum.MEALS) {
await updateAttendeePriority(userId);
}

await updateAttendanceRecords(eventId, userId);


await assignPixelsToUser(userId, event.points);
}

Expand Down

0 comments on commit e178f5b

Please sign in to comment.