Commit 0c9258e5 authored by lixiaofang's avatar lixiaofang

add

parent 3c924b5c
......@@ -10,21 +10,21 @@ import datetime
def click(card_info):
try:
# key = 'have_reply_answer_click:' + str(card_info['card_id'])
# redis_data = redis_client.get(key)
# if redis_data:
# datas = json.loads(str(redis_data, encoding="utf-8"))
# if card_info['current_user_id'] in datas:
# logging.info("当前需要去点赞的用户已经存在了:%s" % card_info)
# return False
#
# else:
# datas.append(card_info['current_user_id'])
# redis_client.set(key, json.dumps(datas))
#
# else:
# conent = [card_info['current_user_id']]
# redis_client.set(key, json.dumps(conent))
key = 'have_reply_answer_click:' + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
datas = json.loads(str(redis_data, encoding="utf-8"))
if card_info['current_user_id'] in datas:
logging.info("当前需要去点赞的用户已经存在了:%s" % card_info)
return False
else:
datas.append(card_info['current_user_id'])
redis_client.set(key, json.dumps(datas))
else:
conent = [card_info['current_user_id']]
redis_client.set(key, json.dumps(conent))
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
......
......@@ -99,30 +99,30 @@ def comment(card_info):
else:
# ###判断一下如果评论为空就重新拿一个
# if not card_info['comment_content']:
# comment = get_vest_userid_and_comment(need_comment_num=1, tag_names=card_info['tag_names'])[0]
# card_info['comment_content'] = comment
#
# ##在这里加一个判断 如果当前的评论的user_id和评论内容已经在这个评论下了就不再下发给同一个回答ID
# else:
# key = 'have_reply_answer_comment:' + str(card_info['card_id'])
# redis_data = redis_client.hget(key, card_info['current_user_id'])
# if redis_data:
# datas = json.loads(str(redis_data, encoding="utf-8"))
# if card_info['comment_content'] in datas:
# logging.info("当前评论和当前的用户已经存在了:%s" % card_info)
# 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))
####当天下发的次数存起来,每次下发判断已经下发了多少个 如果当前下发相等不再下发
###判断一下如果评论为空就重新拿一个
if not card_info['comment_content']:
comment = get_vest_userid_and_comment(need_comment_num=1, tag_names=card_info['tag_names'])[0]
card_info['comment_content'] = comment
##在这里加一个判断 如果当前的评论的user_id和评论内容已经在这个评论下了就不再下发给同一个回答ID
else:
key = 'have_reply_answer_comment:' + str(card_info['card_id'])
redis_data = redis_client.hget(key, card_info['current_user_id'])
if redis_data:
datas = json.loads(str(redis_data, encoding="utf-8"))
if card_info['comment_content'] in datas:
logging.info("当前评论和当前的用户已经存在了:%s" % card_info)
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))
###当天下发的次数存起来,每次下发判断已经下发了多少个 如果当前下发相等不再下发
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_action_comment_answer:" + str(card_info['card_id'])
......
......@@ -10,21 +10,21 @@ import datetime
def follow(card_info):
try:
# key = 'have_reply_answer_follow:' + str(card_info['card_id'])
# redis_data = redis_client.get(key)
# if redis_data:
# datas = json.loads(str(redis_data, encoding="utf-8"))
# if card_info['current_user_id'] in datas:
# logging.info("当前需要去关注的用户已经存在了:%s" % card_info)
# return False
#
# else:
# datas.append(card_info['current_user_id'])
# redis_client.set(key, json.dumps(datas))
#
# else:
# conent = [card_info['current_user_id']]
# redis_client.set(key, json.dumps(conent))
key = 'have_reply_answer_follow:' + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
datas = json.loads(str(redis_data, encoding="utf-8"))
if card_info['current_user_id'] in datas:
logging.info("当前需要去关注的用户已经存在了:%s" % card_info)
return False
else:
datas.append(card_info['current_user_id'])
redis_client.set(key, json.dumps(datas))
else:
conent = [card_info['current_user_id']]
redis_client.set(key, json.dumps(conent))
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
......
......@@ -44,8 +44,8 @@ def kafka_consum(topic_name=None):
# bol_consum = judge_offset_partition_have_consum(card_info=card_info, offset=msg.offset,
# partition=msg.partition)
##在这里先判断当前的数据是否已经存在,存在的话直接PaaS,不存在的话再做下边的处理
bol_consum = judge_data_have_in_redis(card_info)
# bol_consum = True
# bol_consum = judge_data_have_in_redis(card_info)
bol_consum = True
if bol_consum:
logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key), card_info))
......
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