From b2ace0759bb704ba1eb15db012ad4f1b1b61b002 Mon Sep 17 00:00:00 2001 From: amanshah2711 <36978283+amanshah2711@users.noreply.github.com> Date: Tue, 14 Jul 2020 22:53:39 -0400 Subject: [PATCH 1/2] updating oh appts so pending appoints can be restricted by time (#219) --- .../components/admin_appointments_manager.js | 5 +++- oh_queue/views.py | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/oh_queue/static/js/components/admin_appointments_manager.js b/oh_queue/static/js/components/admin_appointments_manager.js index cd3001f..382cc3b 100644 --- a/oh_queue/static/js/components/admin_appointments_manager.js +++ b/oh_queue/static/js/components/admin_appointments_manager.js @@ -61,8 +61,11 @@ function AdminAppointmentsManager({ state }) {

- How many appointments should a student have be pending simultaneously? + How many appointments should a student have be pending simultaneously?

+ (by + + ) = daily_threshold: return socket_error("You have already signed up for {} OH slots for the same day".format(daily_threshold)) - num_pending = AppointmentSignup.query.join(AppointmentSignup.appointment).filter( Appointment.status == AppointmentStatus.pending, AppointmentSignup.user_id == current_user.id, - ).count() - if num_pending >= pending_threshold: - return socket_error("You have already signed up for {} OH slots that have not yet occurred.".format(pending_threshold)) + ) + if pending_metric != 'false': + start = appointment.duration + num_pend = [appt.appointment.duration for appt in list(num_pending)] + threshold = datetime.timedelta(minutes=pending_threshold) + for item in num_pend: + start += item + if start > threshold: + return socket_error("You cannot sign up for more than {} minutes of OH that have not yet occurred.".format(pending_threshold)) + else: + if num_pending.count() >= pending_threshold: + return socket_error("You have already signed up for {} OH slots that have not yet occurred.".format(pending_threshold)) old_signup = AppointmentSignup.query.filter_by( appointment_id=data["appointment_id"], From 3cfbb9bcae1196e2678c4a3cd6c52fb3e004c2b1 Mon Sep 17 00:00:00 2001 From: Vanshaj Singhania Date: Tue, 21 Jul 2020 22:18:22 -0700 Subject: [PATCH 2/2] Switch from floor division to round --- oh_queue/slack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oh_queue/slack.py b/oh_queue/slack.py index 11ca4ba..797d1bb 100644 --- a/oh_queue/slack.py +++ b/oh_queue/slack.py @@ -206,8 +206,8 @@ def send_appointment_summary(app, course): total=upcoming.total, nonempty=upcoming.nonempty, time=upcoming.start_time.strftime("%I:%M%p"), - delta=(upcoming.start_time - get_current_time()).seconds - // 3600, + delta=round((upcoming.start_time - get_current_time()).seconds + / 3600), ), }, }