文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 1b847c12 by 李景熙

completed task

parent c49f1b55
from peewee import * from peewee import *
from dao.model import mysql from dao.model import mysql
import datetime import datetime
from dao import Slice from dao import Slice, Task
class Result: class Result:
...@@ -20,7 +20,7 @@ class Relation(Model): ...@@ -20,7 +20,7 @@ class Relation(Model):
slice_id = IntegerField(null=False) slice_id = IntegerField(null=False)
user_id = IntegerField(null=False) user_id = IntegerField(null=False)
data_id = IntegerField(null=False) data_id = IntegerField(null=False)
result_id = IntegerField() result_id = CharField()
flag = BooleanField(default=False) # 代表该标注关系是否被标注 flag = BooleanField(default=False) # 代表该标注关系是否被标注
score = IntegerField(default=0) score = IntegerField(default=0)
receive_time = DateTimeField(default=datetime.datetime.now()) receive_time = DateTimeField(default=datetime.datetime.now())
...@@ -42,9 +42,20 @@ def create_relation(slice_id, user_id, data_id): ...@@ -42,9 +42,20 @@ def create_relation(slice_id, user_id, data_id):
return Result(1, "create success", {}) return Result(1, "create success", {})
# 查找Relation中与用户id相关的分片列表,用于我的任务的列表显示
def find_slice_by_executor(user_id): def find_slice_by_executor(user_id):
try: try:
slice_list = Relation.select(Relation.slice_id).where(Relation.user_id == user_id) slice_list = Relation.select(Relation.slice_id).where(Relation.user_id == user_id, Relation.flag == 0)
except:
return False
else:
return slice_list
# 查找Relation中与用户id相关的分片列表,用于已完成任务的列表显示
def find_slice_by_completed(user_id):
try:
slice_list = Relation.select(Relation.slice_id).where(Relation.user_id == user_id, Relation.flag == 1)
except: except:
return False return False
else: else:
...@@ -54,8 +65,13 @@ def find_slice_by_executor(user_id): ...@@ -54,8 +65,13 @@ def find_slice_by_executor(user_id):
# 在标注结束之后更改标注关系状态的函数,并存储标注结果(先存储结果,修改完成时间,修改对应任务状态) # 在标注结束之后更改标注关系状态的函数,并存储标注结果(先存储结果,修改完成时间,修改对应任务状态)
def set_result_id(userid, dataid, resultid): def set_result_id(userid, dataid, resultid):
try: try:
print("set_result_id")
relation = Relation.get(Relation.user_id == userid, Relation.data_id == dataid) relation = Relation.get(Relation.user_id == userid, Relation.data_id == dataid)
relation.result_id = resultid relation.result_id = resultid
relation.complete_time = datetime.datetime.now()
relation.flag = True
task_id = Slice.find_task_by_slice(relation.slice_id)
Task.set_state(task_id, 2)
relation.save() relation.save()
except: except:
return False return False
...@@ -66,7 +82,8 @@ def set_result_id(userid, dataid, resultid): ...@@ -66,7 +82,8 @@ def set_result_id(userid, dataid, resultid):
# 获取某用户,某分片的标注进度 # 获取某用户,某分片的标注进度
def get_flag_count(userId, sliceId): def get_flag_count(userId, sliceId):
try: try:
num = Relation.select().where(Relation.user_id == userId, Relation.slice_id == sliceId, Relation.flag == 1).count() num = Relation.select().where(Relation.user_id == userId, Relation.slice_id == sliceId,
Relation.flag == 1).count()
except: except:
return 0 return 0
else: else:
...@@ -76,7 +93,7 @@ def get_flag_count(userId, sliceId): ...@@ -76,7 +93,7 @@ def get_flag_count(userId, sliceId):
def set_flag(id): def set_flag(id):
try: try:
relation = Relation.get(Relation.relation_id == id) relation = Relation.get(Relation.relation_id == id)
relation.flag = 1 relation.flag = True
relation.save() relation.save()
except: except:
return 0 return 0
...@@ -85,6 +102,6 @@ def set_flag(id): ...@@ -85,6 +102,6 @@ def set_flag(id):
if __name__ == '__main__': if __name__ == '__main__':
set_flag(2) Relation.drop_table()
print(get_flag_count(1, 4)) Relation.create_table()
# create_relation(3, 1, 2) # create_relation(3, 1, 2)
...@@ -141,11 +141,13 @@ def find_task_check(creator, start, num): ...@@ -141,11 +141,13 @@ def find_task_check(creator, start, num):
return Result(1, "find success", list, math.ceil(len(find)/num)) return Result(1, "find success", list, math.ceil(len(find)/num))
# 寻找已完成任务(根据所给用户id去Relation表中查询已完成的任务)(需修改) # 寻找已完成任务(根据所给用户id去Relation表中查询已完成的任务)
def find_task_completed(executor, start, num): def find_task_completed(executor, start, num):
try: try:
slice_list = Relation.find_slice_by_completed(executor)
task_list = Slice.find_task_by_slicelist(slice_list)
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where( find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(
Task.task_state == 3) Task.task_id << task_list)
index = 0 index = 0
list = [] list = []
while index < len(find) and index < num: while index < len(find) and index < num:
...@@ -246,6 +248,6 @@ def set_state(task_id, state): ...@@ -246,6 +248,6 @@ def set_state(task_id, state):
if __name__ == '__main__': if __name__ == '__main__':
print(find_task_my_task(1,1,1)) # print(find_task_my_task(1,1,1))
# Task.drop_table() Task.drop_table()
# Task.create_table() Task.create_table()
C:\Users\ljxfai\AppData\Local\Programs\Python\Python37
\ No newline at end of file
xcom
\ No newline at end of file
1.发布任务,审核任务,进行任务后的积分变化
2.我的发布界面修改前后端接口,后端返回该用户发布的所有任务,前端按类型显示是否可修改等。
3.完成“已完成任务”、“待审核任务”两个界面
4.我的任务界面的分片列表中,文件子列表是默认显示的
C:\Users\ljxfai\AppData\Local\Programs\Python\Python37
\ No newline at end of file
删除任务时同步删除任务下的文件(不是data数据库)
多文件上传问题
任务状态变更问题
列表页码bug
\ No newline at end of file
.........
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment