Commit e805dbe9 authored by 李小芳's avatar 李小芳

Merge branch 'group_vest' into 'master'

小组限时

See merge request !42
parents de271f43 adc42138
...@@ -54,8 +54,8 @@ def click(card_info): ...@@ -54,8 +54,8 @@ def click(card_info):
current_user_id = get_vest_userid(need_comment_num=1)[0] current_user_id = get_vest_userid(need_comment_num=1)[0]
status = rpc_invoker['qa/irrigation/create_answer_vote'](user_id=current_user_id, status = rpc_invoker['qa/irrigation/create_answer_vote'](user_id=current_user_id,
answer_id=card_info['card_id']).unwrap() answer_id=card_info['card_id']).unwrap()
logging.info('get_create_answer_vote_status:%s,card_id:%s,耗时:%s' % ( logging.info('get_create_answer_vote_status:%s,card_id:%s,create_time:%s,耗时:%s' % (
status, card_info['card_id'], time.time() - begin)) status, card_info['card_id'], card_info['create_time'], time.time() - begin))
error = status.get('error', 1) error = status.get('error', 1)
if error == 0: if error == 0:
return True return True
......
...@@ -71,8 +71,7 @@ def auto_comment_user(card_info, after_day=False): ...@@ -71,8 +71,7 @@ def auto_comment_user(card_info, after_day=False):
if len(get_time) > 0 and time_region != 3: if len(get_time) > 0 and time_region != 3:
###拿到下发时间后根据下发的时间个数去拿对应个数的马甲账号 ###拿到下发时间后根据下发的时间个数去拿对应个数的马甲账号
all_content = get_vest_userid_and_comment(need_comment_num=len(get_time), all_content = get_vest_userid_and_comment(need_comment_num=len(get_time),
tag_names=tag_names, tag_names=tag_names )
card_id=card_info['card_id'])
userids = get_vest_userid(need_comment_num=len(get_time)) userids = get_vest_userid(need_comment_num=len(get_time))
for i in range(0, len(userids)): for i in range(0, len(userids)):
......
...@@ -108,11 +108,9 @@ def comment(card_info): ...@@ -108,11 +108,9 @@ def comment(card_info):
datas = json.loads(str(redis_data, encoding="utf-8")) datas = json.loads(str(redis_data, encoding="utf-8"))
if card_info['comment_content'] in datas: if card_info['comment_content'] in datas:
return False return False
else: else:
datas.append(card_info['comment_content']) datas.append(card_info['comment_content'])
redis_client.hset(key, card_info['current_user_id'], json.dumps(datas)) redis_client.hset(key, card_info['current_user_id'], json.dumps(datas))
else: else:
conent = [card_info['comment_content']] conent = [card_info['comment_content']]
redis_client.hset(key, card_info['current_user_id'], json.dumps(conent)) redis_client.hset(key, card_info['current_user_id'], json.dumps(conent))
...@@ -150,8 +148,8 @@ def comment(card_info): ...@@ -150,8 +148,8 @@ def comment(card_info):
answer_id=card_info['card_id'], answer_id=card_info['card_id'],
content=card_info[ content=card_info[
'comment_content']).unwrap() 'comment_content']).unwrap()
logging.info('get_create_answer_reply_status:%s,card_id:%s,耗时:%s' % ( logging.info('get_create_answer_reply_status:%s,card_id:%s,create_time:%s,耗时:%s' % (
status, card_info['card_id'], time.time() - begin)) status, card_info['card_id'], card_info['create_time'], time.time() - begin))
error = status.get('error', 1) error = status.get('error', 1)
if error == 0: if error == 0:
......
...@@ -56,7 +56,8 @@ def follow(card_info): ...@@ -56,7 +56,8 @@ def follow(card_info):
followed_user_id=card_info[ followed_user_id=card_info[
'card_user_id']).unwrap() 'card_user_id']).unwrap()
logging.info( logging.info(
'get_user_add_follow_status:%s,card_id:%s,耗时:%s' % (status, card_info['card_id'], time.time() - begin)) 'get_user_add_follow_status:%s,card_id:%s,create_time:%s,耗时:%s' % (
status, card_info['card_id'], card_info['create_time'], time.time() - begin))
error = status.get('error', 1) error = status.get('error', 1)
if error == 0: if error == 0:
......
...@@ -28,13 +28,14 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time="" ...@@ -28,13 +28,14 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
producer = KafkaProducer(bootstrap_servers=settings.KAFKA_BROKER_LIST) producer = KafkaProducer(bootstrap_servers=settings.KAFKA_BROKER_LIST)
topic = settings.KAFKA_TOPIC_NAME topic = settings.KAFKA_TOPIC_NAME
tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc", flag = True
"牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"] # tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
flag = False # "牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
if len(tag_names) > 0: # flag = False
for i in tag_names: # if len(tag_names) > 0:
if i in tag_list: # for i in tag_names:
flag = True # if i in tag_list:
# flag = True
if flag == True: if flag == True:
comment_msg_dict = { comment_msg_dict = {
......
...@@ -303,50 +303,47 @@ def get_vest_userid(need_comment_num=0): ...@@ -303,50 +303,47 @@ def get_vest_userid(need_comment_num=0):
return 12345 return 12345
def get_vest_userid_and_comment(need_comment_num=0, tag_names=[], card_id=0): def get_vest_userid_and_comment(need_comment_num=0, tag_names=[]):
try: try:
##先根据card_id回去内容提取关键字
# logging.info("get settings.HOST:%s" % settings.HOST)
# db_zhengxing_eagle = pymysql.connect(host=settings.HOST, port=settings.PORT, user=settings.USER,
# password=settings.PASSWORD,
# db=settings.NAME)
#
# logging.info("get db_zhengxing_eagle:%s" % db_zhengxing_eagle)
# zhengxing_cursor = db_zhengxing_eagle.cursor()
# sql = 'select content from api_answer where id = %s ' % (card_id)
# zhengxing_cursor.execute(sql)
# data = list(zhengxing_cursor.fetchall())
# logging.info("get data:%s" % data)
# zhengxing_cursor.close()
# if len(data) > 0:
# soup = BeautifulSoup(data[0][0], 'html.parser')
# contents = soup.text
#
# ck = GetContentKeyWords()
# keywords = ck.get_keywords(contents, len(ck.tag_list))
# if keywords:
# tag_names.append(keywords)
if need_comment_num: if need_comment_num:
all_comment_list = [] all_comment_list = []
content = []
redis_key = "vest_kyc_tag_content_data" redis_key = "vest_kyc_tag_content_data"
all_keys = redis_client.hkeys(redis_key) group_keys = "get_group_comment_by_tag:group_id"
all_keys_name = []
for item in all_keys:
all_keys_name.append(str(item, encoding="utf-8"))
for item in tag_names: for item in tag_names:
if item in all_keys_name: ##如果自带的标签有kyc的话走kyc的标签
service_closure_tags = redis_client.hget(redis_key, item) service_closure_tags = redis_client.hget(redis_key, str(item))
if service_closure_tags:
closure_tags = json.loads(str(service_closure_tags, encoding="utf-8")) closure_tags = json.loads(str(service_closure_tags, encoding="utf-8"))
all_comment_list.extend(closure_tags) all_comment_list.extend(closure_tags)
if all_comment_list: if all_comment_list:
content = random.sample(all_comment_list, need_comment_num) content = random.sample(all_comment_list, need_comment_num)
else: else:
content = [] ##没有kyc的标签看标签所属的小组 拿对应小组的数据
all_group_ids = set()
all_comments = []
for item in tag_names:
sql_get_tagid = "select id from api_tag WHERE name = '%s'" % (item)
zhengxing_cursor.execute(sql_get_tagid)
data = zhengxing_cursor.fetchall()
if len(data):
tag_ids = data[0]
# ids = data[0][0]
sql = 'select tag_category_id from api_tag_category_relation where tag_id = %s' % (tag_ids)
zhengxing_cursor.execute(sql)
group_ids = zhengxing_cursor.fetchall()
for item in group_ids:
all_group_ids.add(item[0])
for all_group_id in list(all_group_ids):
get_comment = redis_client.hget(group_keys, int(all_group_id))
if get_comment:
comment = json.loads(str(get_comment, encoding="utf-8"))
all_comment_list.extend(comment)
else: content = random.sample(all_comment_list, need_comment_num)
content = [] zhengxing_cursor.close()
return content return content
except: except:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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