Skip to content
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

Regulate mentorship attendances to be 1.0 points. #150

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/services/AttendanceService.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand Down