Skip to content

Commit

Permalink
Add crosschecking with internal tasks #114 #129
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMadejski committed Aug 21, 2019
1 parent 7f42420 commit c58ca8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions moonsheep/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def verify_and_save(self, entries: List[Entry]) -> bool:
# TODO: do something here
return False

# TODO record somewhere on how many entries the crosscheck was done, update values if new crosscheck comes with higher rank

def cross_check(self, entries: list) -> (dict, float):
"""
Cross check all entries recursively
Expand Down
8 changes: 6 additions & 2 deletions moonsheep/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,17 @@ def choose_a_task(self) -> Task:

def _save_entry(self, task_id, data) -> None:
"""
Save entry in the database
Save entry in the database and run the crosschecking
"""
# TODO in #130
user = None

Entry(task_id=task_id, user=user, data=data).save()
# TODO record that a Entry was saved, when crosscheck should happen?

# Do the crosscheck if we have enough entries
entries = Entry.objects.filter(task_id=task_id)
if entries.count() > 3: # TODO setting how many entries do we want for crosscheck
self.task_type.verify_and_save(list(entries))

def _get_user_ip(self):
return self.request.META.get(
Expand Down

0 comments on commit c58ca8c

Please sign in to comment.