Commit 11f9cc91 authored by lixiaofang's avatar lixiaofang

新增类型

parent 51fb4d05
......@@ -8,7 +8,63 @@ from moment.views.send_email import send_email_tome
def comment(card_info):
"""
在这里需要判断是帖子下发评论还是问答还是日记下发
:param card_info:
:return:
"""
try:
if card_info['card_status'] == 'tractate':
key = "tractate_auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.set(key, json.dumps(redis_data))
else:
redis_data = {"comment": 1}
redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60)
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if comment_num > 20:
return True
# send_email_tome(str(redis_data) + str(card_info))
else:
rpc_invoker = get_rpc_invoker()
rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info['comment_content']).unwrap()
elif card_info['card_status'] == 'diary':
key = "diary_auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.set(key, json.dumps(redis_data))
else:
redis_data = {"comment": 1}
redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60)
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if comment_num > 20:
return True
# send_email_tome(str(redis_data) + str(card_info))
else:
rpc_invoker = get_rpc_invoker()
rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info['comment_content']).unwrap()
else:
key = "auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
......@@ -22,6 +78,7 @@ def comment(card_info):
redis_client.expire(key, time=24 * 60 * 60)
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if comment_num > 20:
return True
......
......@@ -14,6 +14,16 @@ from libs.error import logging_exception
@bind('vest/moment/vest_irrigation')
def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time="", content_level=0, tag_names=[]):
"""
在这里把后端传的数据存进卡夫卡 日记和帖子只需要发评论不需要点赞和关注
:param card_id:
:param card_type:
:param card_user_id:
:param create_time:
:param content_level:
:param tag_names:
:return:
"""
try:
producer = KafkaProducer(bootstrap_servers=settings.KAFKA_BROKER_LIST)
......@@ -32,6 +42,7 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
comment_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -43,9 +54,11 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
logging.info("get comment_msg_dict:%s" % comment_msg_dict)
producer.send(topic, json.dumps(comment_msg_dict).encode())
if card_type == 'answer':
follow_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -60,6 +73,7 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
click_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......
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