Commit e3b0207c authored by 高雅喆's avatar 高雅喆

try except sys.exit and change mysql slave

parent 4396340f
......@@ -16,6 +16,7 @@ from search.utils.common import *
import libs.tools as Tools
from trans2es.models.pictorial import CommunityPictorialHomeFeed
from libs.error import logging_exception
import sys
class KafkaManager(object):
consumser_obj = None
......@@ -77,8 +78,8 @@ class CollectData(object):
have_read_topic_id_list = Tools.get_have_read_topic_id_list(device_id,user_id,TopicPageType.HOME_RECOMMEND)
have_read_lin_pictorial_id_list = Tools.get_have_read_lin_pictorial_id_list(device_id, user_id,
TopicPageType.HOME_RECOMMEND)
promote_recommend_topic_id_list = TopicHomeRecommend.objects.using(settings.SLAVE_DB_NAME).filter(is_online=1).values_list("topic_id",flat=True)
promote_lin_pictorial_id_list = CommunityPictorialHomeFeed.objects.using(settings.SLAVE_DB_NAME).filter(
promote_recommend_topic_id_list = TopicHomeRecommend.objects.using(settings.SLAVE1_DB_NAME).filter(is_online=1).values_list("topic_id",flat=True)
promote_lin_pictorial_id_list = CommunityPictorialHomeFeed.objects.using(settings.SLAVE1_DB_NAME).filter(
is_deleted=0, is_online=1).values_list("pictorial_id", flat=True)
have_read_topic_id_list.extend(promote_recommend_topic_id_list)
have_read_lin_pictorial_id_list.extend(promote_lin_pictorial_id_list)
......@@ -190,13 +191,13 @@ class CollectData(object):
# if collection and is_ai:
# click_topic_tag_list.append(id)
topic_tag_list = list()
click_results = TopicTag.objects.using(settings.SLAVE_DB_NAME).filter(
click_results = TopicTag.objects.using(settings.SLAVE1_DB_NAME).filter(
topic_id=topic_id, is_online=True).values_list("tag_id", "is_collection")
for tag_id, is_collection in click_results:
# topic_tag_list.append(tag_id)
if is_collection:
topic_tag_list.append(tag_id)
tag_query_results = Tag.objects.using(settings.SLAVE_DB_NAME).filter(
tag_query_results = Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
id__in=topic_tag_list, is_online=True, is_deleted=False, is_category=False).values_list("id",
"is_ai")
for id, is_ai in tag_query_results:
......@@ -211,7 +212,7 @@ class CollectData(object):
device_id = raw_val_dict["device"]["device_id"]
user_id = raw_val_dict["user_id"] if "user_id" in raw_val_dict else None
if query_type=="do":
tag_list = list(Tag.objects.using(settings.SLAVE_DB_NAME).filter(name=tag_name,is_online=True,is_deleted=False, is_category=False).values_list("id",flat=True))
tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(name=tag_name,is_online=True,is_deleted=False, is_category=False).values_list("id",flat=True))
click_topic_tag_list.extend(tag_list)
logging.info("query tag attention,positive tag_list,device_id:%s,query_name:%s,tag_list:%s" % (
str(device_id), tag_name, str(click_topic_tag_list)))
......@@ -296,7 +297,7 @@ class CollectData(object):
# if len(exposure_sql_query_results)>0:
if len(tagid_list) > 0:
tag_query_results = list(Tag.objects.using(settings.SLAVE_DB_NAME).filter(
tag_query_results = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
id__in=tagid_list, is_online=True, is_deleted=False,
is_category=False).values_list("id",flat =True))
is_click = 1
......@@ -319,4 +320,5 @@ class CollectData(object):
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
sys.exit()
return False
......@@ -29,7 +29,7 @@ class LinUCB:
cls.default_tag_list = json.loads(redis_tag_data) if redis_tag_data else []
if len(cls.default_tag_list) == 0:
cls.default_tag_list = Tag.objects.using(settings.SLAVE_DB_NAME).filter(is_online=True,collection=1).values_list("id",flat=True)[0:100]
cls.default_tag_list = Tag.objects.using(settings.SLAVE1_DB_NAME).filter(is_online=True,collection=1).values_list("id",flat=True)[0:100]
return cls.default_tag_list
except:
......
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