def update_task(): form = request.get_json() bag_list = form['bag_name'] marker = form['marker'] reviewer = form['reviewer'] mark_search = ModelUtil.query_one("User", "user", {'username': marker}) review_search = ModelUtil.query_one("User", "user", {'username': reviewer}) if mark_search is not None and review_search is not None: for bag in bag_list: message = ModelUtil.query_one(db_name, table_name, {'bag_name': bag}) message['marker'] = marker message['reviewer'] = reviewer message['status'] = 1 ModelUtil.update(db_name, table_name, message) mark_search['mark_list'] = list_set(mark_search['mark_list'], bag_list) update_user_data(mark_search) if marker == reviewer: review_search = mark_search review_search['review_list'] = list_set(review_search['review_list'], bag_list) update_user_data(review_search) return json_response_ok('success') else: return json_response_error(401, 'The user is not exist.'), 200
def load_work_list(): anno_dir = './nfs/lidar_data/labeled_data/' for path in os.listdir(anno_dir): subdir = os.path.join(anno_dir, path) if not os.path.exists(subdir) or path.find('lijie') > -1 or path.find('2018-01') > -1: continue bag_name = "bag-" + path.replace('.json', '') update_time = int(os.stat(subdir).st_mtime) create_time = int(os.stat(subdir).st_ctime) find_bag_name = ModelUtil.query_one(db_name, table_name, {"bag_name": bag_name}) if (find_bag_name is not None and find_bag_name['update_time'] != update_time) or find_bag_name is None: box_num = f_workload(subdir, ['0', '0', '0', '0', '0', '150']) box_num = str(int(round(box_num / 3.0, 2))) else: box_num = find_bag_name['box_num'] if find_bag_name is None: item = dict( bag_name=bag_name, box_num=box_num, update_time=update_time, create_time=create_time ) ModelUtil.add(db_name, table_name, item) ModelUtil.create_index(db_name, table_name, ['bag_name', 'box_num']) print('add %s' % item) elif find_bag_name is not None and find_bag_name['box_num'] != box_num: find_bag_name['box_num'] = box_num find_bag_name['update_time'] = update_time ModelUtil.update(db_name, table_name, find_bag_name) print('update: %s' % find_bag_name) update_request_work_time()
def update_user(cls, data): item = ModelUtil.query_one(map_name, table_name, {"id": data['id']}) for k, v in data.items(): if k in item.keys() and v: item[k] = v ModelUtil.update(map_name, table_name, item) item.pop("_id") return item
def view_user_update(user_id): form = request.get_json() user_message = get_user_message({"id": user_id}) user_error = get_user_message({"username": form["username"]}) if user_message is None: return json_response_error(401, 'The user is not exist.'), 200 elif user_error is not None: return json_response_error(403, 'The user is exist.'), 200 else: user_message["id"] = user_id user_message['username'] = form['username'] user_message['password'] = form['password'] user_message['role'] = form['role'] user_message['remark'] = form['remark'] if 'remark' in form else user_message['remark'] ModelUtil.update(db_name, table_name, user_message) return json_response_ok('success')
def update_user_data(item): ModelUtil.update("User", "user", item)
def update_request_work_time(): if not ModelUtil.exists(db_name, time_name, {}): ModelUtil.add(db_name, time_name, {'updated_time': timestamp()}) else: time = ModelUtil.query_one(db_name, time_name, {}, False) ModelUtil.update(db_name, time_name, time)