Beispiel #1
0
 def marked_sample(cls, result_id, label):
     # trigger two event
     result = CSResultBusiness.read_by_id(result_id)
     result.label = label
     # print('after_result: ', result.to_mongo())
     result.save()
     # 打一个标都记录上去, 同一个标不重复记录
     task = cls._add_marked_count(result.task.id)
     # task.save()
     # 如果打完标签
     results = CSResultBusiness.read_all_by_id(task, task.evaluation)
     sample_marked_for_user, need_marked_times, marked_times = \
         cls._compute_sample_marked_count(results)
     if sample_marked_for_user >= task.total_count:
         # send notification
         admin_user = UserBusiness.get_by_user_ID('admin')
         # reciever = UserBusiness.get_by_id(task.sponsor.id)
         # send notification
         MessageService.create_message(
             admin_user,
             'cs_task_done',
             [task.sponsor],
             user=task.sponsor,
             task=result.task,
             project=result.task.module,
         )
     # all people is labeled, finish this task
     if task.marked_count == task.total_count:
         task.status = 2
         task.save()
         return cls._add_extra_info_with_task(task)
     return None
Beispiel #2
0
 def read_by_id(cls, result_id):
     result = CSResultBusiness.read_by_id(result_id)
     return result