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

Fixes expired tasks pattern. #170

Merged
merged 1 commit into from Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions wikilabels/database/tasks.py
Expand Up @@ -144,14 +144,16 @@ def remove_expired_tasks(self):
cursor = transactor.cursor()
cursor.execute("""
DELETE FROM workset_task
USING workset_task as wt
JOIN workset ON
workset.id = wt.workset_id
LEFT JOIN label ON
label.task_id = wt.task_id
USING workset_task AS wt
JOIN workset AS w ON
w.id = wt.workset_id
LEFT JOIN label AS l ON
l.task_id = wt.task_id AND
l.user_id = w.user_id
WHERE
workset_task.workset_id = wt.workset_id AND
workset_task.task_id = wt.task_id AND
label.data is NULL AND
workset.expires < NOW()
workset_task.workset_id = wt.workset_id AND
l.data is NULL AND
w.expires < NOW()
""")
return cursor.rowcount
2 changes: 1 addition & 1 deletion wikilabels/utilities/remove_expired_tasks.py
Expand Up @@ -34,4 +34,4 @@ def main(argv=None):

def run(db):

db.tasks.remove_expired_tasks()
print(db.tasks.remove_expired_tasks(), " assignments removed.")