Commit aaf451d9 authored by lixiaofang's avatar lixiaofang

修改返回类型

parent c2f1481a
......@@ -99,8 +99,9 @@ class QueryWordAttr(object):
try:
key = cls.tips_num_redis_key_prefix + str(id)
results_num = redis_client.get(key)
# results_num = json.loads(str(redis_data, encoding="utf-8")) if redis_data else {}
logging.info("get results_num:%s" % results_num)
if results_num == None:
return 0
return int(results_num)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
......@@ -37,7 +37,7 @@ def get_suggest_tips(query, agile_tag_type):
agile_type_id = set()
logging.info("get agile_tag_type:%s" % agile_tag_type)
if agile_tag_type > 0:
if int(agile_tag_type) > 0:
q = {
"query": {
"term": {
......@@ -70,8 +70,8 @@ def get_suggest_tips(query, agile_tag_type):
highlight_name = hit_item["_source"]["highlight_name"]
ret_list.append(
[{"agile_tag_id": agile_tag_id, "ori_name": ori_name, "results_num": results_num,
"highlight": highlight_name}])
{"agile_tag_id": agile_tag_id, "ori_name": ori_name, "results_num": results_num,
"highlight": highlight_name})
else:
for tips_item in result_dict["suggest"]["tips-suggest"]:
......@@ -87,8 +87,8 @@ def get_suggest_tips(query, agile_tag_type):
highlight_name = hit_item["_source"]["highlight_name"]
ret_list.append(
[{"agile_tag_id": agile_tag_id, "ori_name": ori_name, "results_num": results_num,
"highlight": highlight_name}])
{"agile_tag_id": agile_tag_id, "ori_name": ori_name, "results_num": results_num,
"highlight": highlight_name})
return ret_list
except:
......
......@@ -98,7 +98,7 @@ class TagTransfer(object):
name = agile_tag.AgileTag.objects.filter(id=instance.agile_tag_id).values_list("name", flat=True).first()
tractate_results = TagTransfer.get_tractate_data_name_mapping_results_to_redis(name)
if tractate_results == None:
tractate_results =0
tractate_results = 0
logging.info("get tractate_results:%s" % tractate_results)
key = query_key + str(instance.agile_tag_id)
redis_client.set(key, tractate_results)
......
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