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

Commit 693f3927 by 李景熙

修改审核界面中的进度显示问题

parent 78bb1298
...@@ -5,6 +5,10 @@ from dao import Slice, Task, User ...@@ -5,6 +5,10 @@ from dao import Slice, Task, User
class Result: class Result:
code: int
message: []
data: {}
def __init__(self, code, message, data): def __init__(self, code, message, data):
self.code = code self.code = code
self.message = message self.message = message
...@@ -40,10 +44,11 @@ def create_relation(slice_id, user_id, data_id): ...@@ -40,10 +44,11 @@ def create_relation(slice_id, user_id, data_id):
# 设置标注关系的打分数值 # 设置标注关系的打分数值
def set_grade(user_id, data_id, score): def set_grade(user_id, slice_id, score):
try: try:
relation = Relation.get(Relation.user_id == user_id, Relation.data_id == data_id) relation = Relation.get(Relation.user_id == user_id, Relation.slice_id == slice_id)
relation.score = score relation.score = score
relation.flag2 = True
relation.save() relation.save()
except: except:
return Result(0, "grade failed", {}) return Result(0, "grade failed", {})
...@@ -120,6 +125,7 @@ def get_completed_num(sliceId): ...@@ -120,6 +125,7 @@ def get_completed_num(sliceId):
else: else:
return num return num
# 获取某用户,某分片的标注进度 # 获取某用户,某分片的标注进度
def get_flag_count(userId, sliceId): def get_flag_count(userId, sliceId):
try: try:
...@@ -164,7 +170,7 @@ def get_state(user_id, data_id): ...@@ -164,7 +170,7 @@ def get_state(user_id, data_id):
# 获取某文件的标注者信息 # 获取某文件的标注者信息
def get_executors(data_id): def get_executors(data_id):
try: try:
find = Relation.select(Relation.user_id, Relation.relation_id).where(Relation.data_id == data_id, Relation.flag == 1, Relation.flag2 == 0) find = Relation.select(Relation.user_id, Relation.relation_id).where(Relation.data_id == data_id)
index = 0 index = 0
list = [] list = []
while index < len(find): while index < len(find):
...@@ -193,8 +199,7 @@ def get_relation_id(uid, did): ...@@ -193,8 +199,7 @@ def get_relation_id(uid, did):
if __name__ == '__main__': if __name__ == '__main__':
# Relation.drop_table() Relation.drop_table()
# Relation.create_table() Relation.create_table()
print(get_executors(4).data)
# print(get_state(1, 5)) # print(get_state(1, 5))
# create_relation(3, 1, 2) # create_relation(3, 1, 2)
...@@ -17,7 +17,7 @@ def get_tasks(): ...@@ -17,7 +17,7 @@ def get_tasks():
state = request.args.get('state') state = request.args.get('state')
# get函数用于可选参数,在未接收到参数时返回空值 # get函数用于可选参数,在未接收到参数时返回空值
if keyword: if keyword:
ret = Task.find_task_by_name(keyword, pagesize * (currentpage - 1), pagesize) ret = Task.find_task_by_name(keyword, pagesize*(currentpage-1), pagesize)
elif creator: elif creator:
if state: if state:
ret = Task.find_task_check(creator, pagesize * (currentpage - 1), pagesize) ret = Task.find_task_check(creator, pagesize * (currentpage - 1), pagesize)
...@@ -29,7 +29,7 @@ def get_tasks(): ...@@ -29,7 +29,7 @@ def get_tasks():
else: else:
ret = Task.find_task_my_task(executor, pagesize * (currentpage - 1), pagesize) ret = Task.find_task_my_task(executor, pagesize * (currentpage - 1), pagesize)
else: else:
ret = Task.find_task(pagesize * (currentpage - 1), pagesize) ret = Task.find_task(pagesize*(currentpage-1), pagesize)
res = { res = {
'code': ret.code, 'code': ret.code,
'message': ret.message, 'message': ret.message,
...@@ -44,8 +44,8 @@ def get_tasks(): ...@@ -44,8 +44,8 @@ def get_tasks():
@task.route("/createTask", methods=["Post"]) @task.route("/createTask", methods=["Post"])
def create_task(): def create_task():
data = request.get_json(silent=True) data = request.get_json(silent=True)
print(data)
id = int(data['taskId']) id = int(data['taskId'])
userid=int(data['userId'])
if id >= 0: if id >= 0:
find_slice = Slice.find_slice_by_task(id) find_slice = Slice.find_slice_by_task(id)
if find_slice.code == 1: if find_slice.code == 1:
...@@ -56,10 +56,8 @@ def create_task(): ...@@ -56,10 +56,8 @@ def create_task():
Task.delete_task(id) Task.delete_task(id)
ret = Task.create_task(data['userId'], data['taskName']) ret = Task.create_task(data['userId'], data['taskName'])
tid = ret.data tid = ret.data
score=len(data['task']['domains'])+len(data['task']['pictureDomains'])+len(data['task']['layerDomains'])
if ret.code==1:
User.add_post_score(userid,score)
i = 0 i = 0
print(data)
while i < len(data['task']['domains']): while i < len(data['task']['domains']):
s = Slice.create_text_slice(tid, data['task']['domains'][i]['templateId']) s = Slice.create_text_slice(tid, data['task']['domains'][i]['templateId'])
j = 0 j = 0
...@@ -96,6 +94,7 @@ def create_task(): ...@@ -96,6 +94,7 @@ def create_task():
} }
return json.dumps(res) return json.dumps(res)
@task.route("/deleteTask", methods=["GET"]) @task.route("/deleteTask", methods=["GET"])
def delete_task(): def delete_task():
taskId = request.args['taskId'] taskId = request.args['taskId']
...@@ -214,10 +213,10 @@ def grade(): ...@@ -214,10 +213,10 @@ def grade():
else: else:
User.add_image_score(userId, score) User.add_image_score(userId, score)
ret = Relation.set_grade(userId, data_id, score) ret = Relation.set_grade(userId, slice_id, score)
res = { res = {
'code': ret.code, 'code': ret.code,
'message': ret.message, 'message': ret.message,
'data': ret.data 'data': ret.data
} }
return json.dumps(res) return json.dumps(res)
\ 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