diff --git a/sorteerhoed/HITStore.py b/sorteerhoed/HITStore.py index 8e7d6d6..c4834b1 100644 --- a/sorteerhoed/HITStore.py +++ b/sorteerhoed/HITStore.py @@ -84,7 +84,7 @@ class HIT(Base): return "accepted by worker" # on abandon: if self.worker_id: - return "abandoned / awaiting worker" + return "abandoned by worker" return "awaiting worker" @@ -166,7 +166,7 @@ class Store: return self.getAvgDurationOfPreviousNHits(5) def getHitTimeout(self): - return max(200, self.getAvgDurationOfPreviousNHits(5)*2) + return max(160, self.getAvgDurationOfPreviousNHits(5)*2) def getHITs(self, n = 100): return self.session.query(HIT).\ diff --git a/sorteerhoed/central_management.py b/sorteerhoed/central_management.py index f44922b..4299371 100644 --- a/sorteerhoed/central_management.py +++ b/sorteerhoed/central_management.py @@ -230,6 +230,7 @@ class CentralManagement(): sqsHit.submit_hit_at = datetime.datetime.utcnow() # fake submit if updateStatus: self.setLight(False) + self.mturk.create_worker_block(WorkerId=signal.params['event']['WorkerId'], Reason='Accepted task without working on it.') elif signal.name == 'sqs.AssignmentReturned': self.logger.info(f'Set status progress to returned') @@ -251,7 +252,15 @@ class CentralManagement(): if sqsHit.uuid not in sqsHit.answer: self.logger.critical(f"Not a valid answer given?! {sqsHit.answer}") - sqsHit.submit_hit_at = datetime.datetime.strptime(signal.params['event']['EventTimestamp'],"%Y-%m-%dT%H:%M:%SZ") + if not sqsHit.submit_page_at: + # page not submitted, hit is. Nevertheless, create new hit. + try: + self.mturk.reject_assignment(AssignmentId=signal.params['event']['AssignmentId'], RequesterFeedback='Did not do the assignment') + except Exception as e: + self.logger.exception(e) + self.makeHit() + else: + sqsHit.submit_hit_at = datetime.datetime.strptime(signal.params['event']['EventTimestamp'],"%Y-%m-%dT%H:%M:%SZ") self.store.saveHIT(sqsHit)