def save_sort(self): """Save custom sort.""" try: data = request.get_json() index_id = data.get("q_id") sort_data = data.get("sort") # save data to DB item_sort = {} for sort in sort_data: item_sort[sort.get('id')] = sort.get('custom_sort').get( index_id) Indexes.set_item_sort_custom(index_id, item_sort) # update es fp = Indexes.get_self_path(index_id) Indexes.update_item_sort_custom_es(fp.path, sort_data) jfy = {} jfy['status'] = 200 jfy['message'] = 'Data is successfully updated.' return make_response(jsonify(jfy), jfy['status']) except Exception as ex: jfy['status'] = 405 jfy['message'] = 'Error' return make_response(jsonify(jfy), jfy['status'])
def save_sort(self): """Save custom sort.""" try: data = request.get_json() index_id = data.get("q_id") sort_data = data.get("sort") # save data to DB item_sort = {} for sort in sort_data: sd = sort.get('custom_sort').get(index_id) if sd: item_sort[sort.get('id')] = sd Indexes.set_item_sort_custom(index_id, item_sort) # update es # fp = Indexes.get_self_path(index_id) # Indexes.update_item_sort_custom_es(fp.path, sort_data) jfy = {'status': 200, 'message': 'Data is successfully updated.'} except Exception: jfy = {'status': 405, 'message': 'Error.'} return make_response(jsonify(jfy), jfy['status'])