Commit adc42138 authored by lixiaofang's avatar lixiaofang

小组限时

parent de271f43
......@@ -54,8 +54,8 @@ def click(card_info):
current_user_id = get_vest_userid(need_comment_num=1)[0]
status = rpc_invoker['qa/irrigation/create_answer_vote'](user_id=current_user_id,
answer_id=card_info['card_id']).unwrap()
logging.info('get_create_answer_vote_status:%s,card_id:%s,耗时:%s' % (
status, card_info['card_id'], time.time() - begin))
logging.info('get_create_answer_vote_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)
if error == 0:
return True
......
......@@ -71,8 +71,7 @@ def auto_comment_user(card_info, after_day=False):
if len(get_time) > 0 and time_region != 3:
###拿到下发时间后根据下发的时间个数去拿对应个数的马甲账号
all_content = get_vest_userid_and_comment(need_comment_num=len(get_time),
tag_names=tag_names,
card_id=card_info['card_id'])
tag_names=tag_names )
userids = get_vest_userid(need_comment_num=len(get_time))
for i in range(0, len(userids)):
......
......@@ -108,11 +108,9 @@ def comment(card_info):
datas = json.loads(str(redis_data, encoding="utf-8"))
if card_info['comment_content'] in datas:
return False
else:
datas.append(card_info['comment_content'])
redis_client.hset(key, card_info['current_user_id'], json.dumps(datas))
else:
conent = [card_info['comment_content']]
redis_client.hset(key, card_info['current_user_id'], json.dumps(conent))
......@@ -150,8 +148,8 @@ def comment(card_info):
answer_id=card_info['card_id'],
content=card_info[
'comment_content']).unwrap()
logging.info('get_create_answer_reply_status:%s,card_id:%s,耗时:%s' % (
status, card_info['card_id'], time.time() - begin))
logging.info('get_create_answer_reply_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)
if error == 0:
......
......@@ -56,7 +56,8 @@ def follow(card_info):
followed_user_id=card_info[
'card_user_id']).unwrap()
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)
if error == 0:
......
......@@ -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)
topic = settings.KAFKA_TOPIC_NAME
tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
"牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
flag = False
if len(tag_names) > 0:
for i in tag_names:
if i in tag_list:
flag = True
flag = True
# tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
# "牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
# flag = False
# if len(tag_names) > 0:
# for i in tag_names:
# if i in tag_list:
# flag = True
if flag == True:
comment_msg_dict = {
......
......@@ -303,50 +303,47 @@ def get_vest_userid(need_comment_num=0):
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:
##先根据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:
all_comment_list = []
content = []
redis_key = "vest_kyc_tag_content_data"
all_keys = redis_client.hkeys(redis_key)
all_keys_name = []
for item in all_keys:
all_keys_name.append(str(item, encoding="utf-8"))
group_keys = "get_group_comment_by_tag:group_id"
for item in tag_names:
if item in all_keys_name:
service_closure_tags = redis_client.hget(redis_key, item)
##如果自带的标签有kyc的话走kyc的标签
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"))
all_comment_list.extend(closure_tags)
if all_comment_list:
content = random.sample(all_comment_list, need_comment_num)
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 = []
content = random.sample(all_comment_list, need_comment_num)
zhengxing_cursor.close()
return content
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