Commit 7cf48d2a authored by 李小芳's avatar 李小芳

name

parent 663d7629
...@@ -3,6 +3,7 @@ from collections import defaultdict ...@@ -3,6 +3,7 @@ from collections import defaultdict
from data_sync.utils import to_epoch, tzlc from data_sync.utils import to_epoch, tzlc
from qa.models.answer import AnswerTop, QuestionTag from qa.models.answer import AnswerTop, QuestionTag
from utils.rpc import get_rpc_invoker from utils.rpc import get_rpc_invoker
from talos.services.tag import TagService
rpc = get_rpc_invoker() rpc = get_rpc_invoker()
...@@ -35,8 +36,8 @@ def get_qa_tops(pks): ...@@ -35,8 +36,8 @@ def get_qa_tops(pks):
} }
tag_ids = q_top_tags.get(qa_top.question_id, []) tag_ids = q_top_tags.get(qa_top.question_id, [])
_data["tag_ids"] = tag_ids _data["tag_ids"] = tag_ids
_data['closure_tag_ids'] = rpc['api/tag/closure_tags'](tag_ids=tag_ids) if tag_ids else [] # _data['closure_tag_ids'] = rpc['api/tag/closure_tags'](tag_ids=tag_ids) if tag_ids else []
_data['closure_tag_ids'] =[item.get("tag_id") for item in TagService.get_tags_info_by_ids(tag_ids=tag_ids)]
results.append(_data) results.append(_data)
for result in results: for result in results:
......
...@@ -159,11 +159,13 @@ def get_questions(pks): ...@@ -159,11 +159,13 @@ def get_questions(pks):
question_ids = list(queryset.values_list('id', flat=True)) question_ids = list(queryset.values_list('id', flat=True))
users = rpc['api/user/get_fundamental_info_by_user_ids'](user_ids=user_ids) users = rpc['api/user/get_fundamental_info_by_user_ids'](user_ids=user_ids)
user_dict = {str(user['id']): user for user in users.unwrap()}
# tags = rpc['api/tag/info_by_ids'](tag_ids=tag_ids) # tags = rpc['api/tag/info_by_ids'](tag_ids=tag_ids)
tags =TagService.get_tags_info_by_ids(tag_ids=tag_ids) tags = TagService.get_tags_info_by_ids(tag_ids=tag_ids)
tag_dict = {str(tag['tag_id']): tag for tag in tags}
doctors = rpc['doctor/user/get_doctors'](user_ids=user_ids) doctors = rpc['doctor/user/get_doctors'](user_ids=user_ids)
user_dict = {str(user['id']): user for user in users.unwrap()}
tag_dict = {str(tag['id']): tag for tag in tags.unwrap()}
doctor_list = doctors.unwrap()['doctors'] doctor_list = doctors.unwrap()['doctors']
doctor_user_ids = [str(doctor.get('user') or doctor.get('user_id')) for doctor in doctor_list] doctor_user_ids = [str(doctor.get('user') or doctor.get('user_id')) for doctor in doctor_list]
doctor_dict = {str(doctor.get('user') or doctor.get('user_id')): doctor for doctor in doctor_list} doctor_dict = {str(doctor.get('user') or doctor.get('user_id')): doctor for doctor in doctor_list}
...@@ -197,10 +199,10 @@ def get_questions(pks): ...@@ -197,10 +199,10 @@ def get_questions(pks):
# tag # tag
tag_ids = list( tag_ids = list(
filter(lambda t: str(t) in tag_dict, QuestionTag.objects.filter(question=q).values_list('tag', flat=True))) filter(lambda t: str(t) in tag_dict, QuestionTag.objects.filter(question=q).values_list('tag', flat=True)))
res['tags'] = [tag_dict[str(tag_id)]['name'] for tag_id in tag_ids] res['tags'] = [tag_dict[str(tag_id)]['tag_name'] for tag_id in tag_ids]
res['tag_ids'] = tag_ids res['tag_ids'] = tag_ids
# res['closure_tag_ids'] = rpc['api/tag/closure_tags'](tag_ids=tag_ids) if tag_ids else [] # res['closure_tag_ids'] = rpc['api/tag/closure_tags'](tag_ids=tag_ids) if tag_ids else []
res['closure_tag_ids'] =TagService.get_tags_info_by_ids(tag_ids=tag_ids) res['closure_tag_ids'] = [item.get("tag_id") for item in TagService.get_tags_info_by_ids(tag_ids=tag_ids)]
fresh_tag_result = rpc["api/agile_tag/tuple_new_tags"](old_tag_ids=tag_ids) fresh_tag_result = rpc["api/agile_tag/tuple_new_tags"](old_tag_ids=tag_ids)
fresh_tag_id_list = list() fresh_tag_id_list = list()
fresh_tag_name_list = list() fresh_tag_name_list = list()
......
...@@ -383,15 +383,14 @@ class QuestionTag(models.Model): ...@@ -383,15 +383,14 @@ class QuestionTag(models.Model):
# manager = TagManager() # manager = TagManager()
name = list() name = list()
# ma = manager.__call__(tag_list) # ma = manager.__call__(tag_list)
all_tags=TagService.get_tags_info_by_ids(tag_ids=tag_list) all_tags = TagService.get_tags_info_by_ids(tag_ids=tag_list)
for i in all_tags: name.extend([i.get("tag_name") for i in all_tags])
name.append(i.get("name"))
return name return name
def get_project_tags(self, tag_list): def get_project_tags(self, tag_list):
try: try:
tag_list = TagService.get_tags_info_by_ids(list(tag_list)) tag_list = TagService.get_tags_info_by_ids(list(tag_list))
return [t.get("name") for t in tag_list if return [t.get("tag_name") for t in tag_list if
t.get("tag_type") in (TAG_TYPE.BODY_PART, TAG_TYPE.BODY_PART_SUB_ITEM, TAG_TYPE.ITEM_WIKI)] t.get("tag_type") in (TAG_TYPE.BODY_PART, TAG_TYPE.BODY_PART_SUB_ITEM, TAG_TYPE.ITEM_WIKI)]
except: except:
return [] return []
...@@ -1111,19 +1110,19 @@ class Answer(models.Model): ...@@ -1111,19 +1110,19 @@ class Answer(models.Model):
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 1000 return 1000
#
def get_answer_tag(self, tag_list): # def get_answer_tag(self, tag_list):
try: # try:
association_tags_id_list = list() # association_tags_id_list = list()
tag_list = TagService.get_tags_info_by_ids(tag_list) # tag_list = TagService.get_tags_info_by_ids(tag_list)
for item in tag_list: # for item in tag_list:
association_tags_id_list.append( # association_tags_id_list.append(
{"id": item.get("id"), "tag_name": item.get("name"), "recommend_type": item.get("recommend_type"), # {"id": item.get("id"), "tag_name": item.get("name"), "recommend_type": item.get("recommend_type"),
"tag_type": item.get("tag_type")}) # "tag_type": item.get("tag_type")})
return association_tags_id_list # return association_tags_id_list
except: # except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) # logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] # return []
def get_om_answer_tags_info(self, ids): def get_om_answer_tags_info(self, ids):
r = get_current_rpc_invoker() r = get_current_rpc_invoker()
......
...@@ -317,7 +317,7 @@ class Tractate(models.Model): ...@@ -317,7 +317,7 @@ class Tractate(models.Model):
tag_list = TagService.get_tags_info_by_ids(tag_list) tag_list = TagService.get_tags_info_by_ids(tag_list)
for item in tag_list: for item in tag_list:
association_tags_id_list.append( association_tags_id_list.append(
{"id": item.get("id"), "tag_name": item.get("name"), "recommend_type": item.get("recommend_type"), {"id": item.get("tag_id"), "tag_name": item.get("tag_name"), "recommend_type": item.get("recommend_type"),
"tag_type": item.get("tag_type")}) "tag_type": item.get("tag_type")})
return association_tags_id_list return association_tags_id_list
except: except:
...@@ -341,7 +341,7 @@ class Tractate(models.Model): ...@@ -341,7 +341,7 @@ class Tractate(models.Model):
tag_list = TagService.get_tags_info_by_ids(tag_list) tag_list = TagService.get_tags_info_by_ids(tag_list)
for item in tag_list: for item in tag_list:
if int(item.get("recommend_type")) != 5 or int(item.get("tag_type")) != 11: if int(item.get("recommend_type")) != 5 or int(item.get("tag_type")) != 11:
association_tags_id_list.append(item.name) association_tags_id_list.append(item.get("tag_name"))
return association_tags_id_list return association_tags_id_list
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
...@@ -11,7 +11,7 @@ from brain.library.v1.library_grpc_client import LibraryGrpcClient ...@@ -11,7 +11,7 @@ from brain.library.v1.library_grpc_client import LibraryGrpcClient
from google.protobuf import json_format from google.protobuf import json_format
from django.conf import settings from django.conf import settings
import json import json
from django.settings import BRAIN_SERVER, BRAIN_PORT from django.conf import BRAIN_SERVER, BRAIN_PORT
from gm_types.gaia import AUTHOR_TYPE, TAG_TYPE from gm_types.gaia import AUTHOR_TYPE, TAG_TYPE
......
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