From 13d212d740963935976dcf99a4c8fc96093967be Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 5 Sep 2019 12:41:47 +0100 Subject: Don't assign task to user that has unfinished tasks --- app/utils/tasks.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/utils/tasks.py b/app/utils/tasks.py index 5629d46..2bf49ad 100644 --- a/app/utils/tasks.py +++ b/app/utils/tasks.py @@ -27,6 +27,13 @@ def generate_user_task(user): user_tasks = Task.query.filter_by(annotator_id=user.id).all() user_tasks = [t for t in user_tasks if not t.dataset.is_demo] + + # don't assign a new task if the user has assigned tasks + not_done = [t for t in user_tasks if not t.done] + if len(not_done) > 0: + return None + + # don't assign a new task if the user has reached maximum n_user_tasks = len(user_tasks) if n_user_tasks >= max_per_user: return None -- cgit v1.2.3