From 679f3a72601ac69b96c33782a1520b22d7aee90a Mon Sep 17 00:00:00 2001 From: gypang Date: Sun, 15 Nov 2020 16:13:16 -0800 Subject: [PATCH] Regulate mentorship attendances to be 1.0 points. Mentorship events attendance should be 1 points regardless of sign in and check off time. --- src/services/AttendanceService.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/AttendanceService.ts b/src/services/AttendanceService.ts index 6f9289c8..3ec14030 100644 --- a/src/services/AttendanceService.ts +++ b/src/services/AttendanceService.ts @@ -1,4 +1,4 @@ -import { Attendance, AppUser, AppUserRole, Event } from '@Entities'; +import { Attendance, AppUser, AppUserRole, Event, EventType } from '@Entities'; import { MultipleAttendanceQuery } from '@Payloads'; import { AppUserService, AppUserServiceImpl } from './AppUserService'; @@ -104,7 +104,12 @@ export class AttendanceService { return attendanceRepository.save(attendance); } + // Precondition: event is fetched within attendance getAttendancePoints(attendance: Attendance): number { + if (attendance.event.type === EventType.MENTORSHIP) { + return 1.0; + } + const diffMinutes: number = differenceInMinutes(attendance.endTime, attendance.startTime); const numHalfHours: number = diffMinutes / 30; const points: number = Math.round(numHalfHours / 2);