From a2769e23c1d5c6d457d8f4b4eaec53da20a6a1a9 Mon Sep 17 00:00:00 2001 From: Thant Htoo Zaw Date: Wed, 4 Mar 2020 14:56:36 -0800 Subject: [PATCH] Automatically deactivate team if their absent count exceeds threshold (#16) * Absent count * corrected some bugs * removed unnecessary comments * fixing bugs * Move absent deactivation outside of retry function * more bugs * yaml gets prioritized * updated the threshold from 1 to 4 * removed absent header cell * added the threshold absent count * Removed some unnecessary lines * updated threshold * Delete redundant absent length Co-authored-by: Thant Htoo Zaw --- app.json | 3 ++- config.template.yaml | 4 +++- config.vagrant.yaml | 1 + gavel/controllers/judge.py | 4 ++++ gavel/settings.py | 1 + gavel/templates/admin.html | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index 9808adac..db4adb05 100644 --- a/app.json +++ b/app.json @@ -22,7 +22,8 @@ "EMAIL_USER": "_unused_", "EMAIL_PASSWORD": "_unused_", "IGNORE_CONFIG_FILE": "true", - "TRACKS": [] + "TRACKS": [], + "THRESHOLD_ABSENT": 4 }, "keywords": [ "gavel", diff --git a/config.template.yaml b/config.template.yaml index a9cf1cba..4a8e399c 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -188,4 +188,6 @@ send_stats: null # defaults to empty list(no tracks) # # this setting defines any sub-categories('tracks') that contestants can compete in -tracks: null \ No newline at end of file +tracks: null + +threshold_absent: 4 diff --git a/config.vagrant.yaml b/config.vagrant.yaml index ec263d61..d9528be9 100644 --- a/config.vagrant.yaml +++ b/config.vagrant.yaml @@ -7,3 +7,4 @@ email_from: '' # needs to be set to something even though email is disabled email_user: '' email_password: '' send_stats: false # disabled for development +threshold_absent: 4 diff --git a/gavel/controllers/judge.py b/gavel/controllers/judge.py index 48bce69d..70c66bdd 100644 --- a/gavel/controllers/judge.py +++ b/gavel/controllers/judge.py @@ -86,6 +86,8 @@ def tx(): elif request.form['action'] == 'Absent': annotator.next.absent.append(annotator) annotator.ignore.append(annotator.next) + if len(annotator.next.absent) >= settings.THRESHOLD_ABSENT: + annotator.next.active = False else: # ignore things that were deactivated in the middle of judging if annotator.prev.active and annotator.next.active: @@ -121,6 +123,8 @@ def tx(): annotator.next = None # will be reset in index elif request.form['action'] == 'Absent' : annotator.next.absent.append(annotator) + if len(annotator.next.absent) >= settings.THRESHOLD_ABSENT: + annotator.next.active = False annotator.next = None db.session.commit() with_retries(tx) diff --git a/gavel/settings.py b/gavel/settings.py index 81d5328a..bacee502 100644 --- a/gavel/settings.py +++ b/gavel/settings.py @@ -84,3 +84,4 @@ def _list(item): USE_SENDGRID = _bool(c.get('use_sendgrid', 'USE_SENDGRID', default=False)) SENDGRID_API_KEY = c.get('sendgrid_api_key','SENDGRID_API_KEY', default=None) TRACKS = c.get('tracks', 'TRACKS', default=[]) +THRESHOLD_ABSENT = c.get('threshold_absent','THRESHOLD_ABSENT') diff --git a/gavel/templates/admin.html b/gavel/templates/admin.html index d4364552..fab24bf7 100644 --- a/gavel/templates/admin.html +++ b/gavel/templates/admin.html @@ -31,7 +31,7 @@

Projects

Mu Sigma Squared Votes - Seen + Seen Skipped Absent {% for track in tracks %}