Commit 7442a922 authored by lixiaofang's avatar lixiaofang

auto_vest

parent 5f40f1c5
...@@ -14,23 +14,23 @@ def click(card_info): ...@@ -14,23 +14,23 @@ def click(card_info):
rpc_invoker['qa/irrigation/create_answer_vote'](user_id=card_info['current_user_id'], rpc_invoker['qa/irrigation/create_answer_vote'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id']).unwrap() answer_id=card_info['card_id']).unwrap()
key = "auto_vest_one_user_action:" + card_info['card_id'] key = "auto_vest_one_user_action:" + card_info['card_id']
redis_data = redis_client.get(key) # redis_data = redis_client.get(key)
if redis_data: # if redis_data:
redis_data = json.loads(redis_data) # redis_data = json.loads(redis_data)
click_num = int(redis_data.get("click")) + 1 # click_num = int(redis_data.get("click")) + 1
redis_data['click'] = click_num # redis_data['click'] = click_num
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
else: # else:
redis_data = {"click": 1, "follow": 0, "comment": 0} # redis_data = {"click": 1, "follow": 0, "comment": 0}
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60) # redis_client.expire(key, time=24 * 60 * 60)
#
logging.info("get redis_data:%s" % redis_data) # logging.info("get redis_data:%s" % redis_data)
#
values = list(redis_data.values()) # values = list(redis_data.values())
s = [True for i in values if i > 0] # s = [True for i in values if i > 0]
if len(s) > 0: # if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info)) # send_email_tome(str(redis_data) + str(card_info))
return True return True
except: except:
......
...@@ -6,32 +6,32 @@ from libs.cache import redis_client ...@@ -6,32 +6,32 @@ from libs.cache import redis_client
import json import json
from moment.views.send_email import send_email_tome from moment.views.send_email import send_email_tome
def comment(card_info): def comment(card_info):
try: try:
rpc_invoker = get_rpc_invoker() rpc_invoker = get_rpc_invoker()
rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'], rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'], answer_id=card_info['card_id'],
content=card_info['comment_content']).unwrap() content=card_info['comment_content']).unwrap()
#### ####
key = "auto_vest_one_user_action:" + card_info['card_id'] # key = "auto_vest_one_user_action:" + card_info['card_id']
redis_data = redis_client.get(key) # redis_data = redis_client.get(key)
if redis_data: # if redis_data:
redis_data = json.loads(redis_data) # redis_data = json.loads(redis_data)
click_num = int(redis_data.get("comment")) + 1 # click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num # redis_data['comment'] = click_num
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
else: # else:
redis_data = {"click": 0, "follow": 0, "comment": 1} # redis_data = {"click": 0, "follow": 0, "comment": 1}
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60) # redis_client.expire(key, time=24 * 60 * 60)
#
logging.info("get redis_data:%s" % redis_data) # logging.info("get redis_data:%s" % redis_data)
#
values = list(redis_data.values()) # values = list(redis_data.values())
s = [True for i in values if i > 0] # s = [True for i in values if i > 0]
if len(s) > 0: # if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info)) # send_email_tome(str(redis_data) + str(card_info))
return True return True
except: except:
......
...@@ -13,23 +13,23 @@ def follow(card_info): ...@@ -13,23 +13,23 @@ def follow(card_info):
rpc_invoker['api/irrigation/user_add_follow'](follow_user_id=card_info['current_user_id'], rpc_invoker['api/irrigation/user_add_follow'](follow_user_id=card_info['current_user_id'],
followed_user_id=card_info['card_user_id']).unwrap() followed_user_id=card_info['card_user_id']).unwrap()
key = "auto_vest_one_user_action:" + card_info['card_id'] # key = "auto_vest_one_user_action:" + card_info['card_id']
redis_data = redis_client.get(key) # redis_data = redis_client.get(key)
if redis_data: # if redis_data:
redis_data = json.loads(redis_data) # redis_data = json.loads(redis_data)
click_num = int(redis_data.get("follow")) + 1 # click_num = int(redis_data.get("follow")) + 1
redis_data['follow'] = click_num # redis_data['follow'] = click_num
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
else: # else:
redis_data = {"click": 0, "follow": 1, "comment": 0} # redis_data = {"click": 0, "follow": 1, "comment": 0}
redis_client.set(key, json.dumps(redis_data)) # redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60) # redis_client.expire(key, time=24 * 60 * 60)
#
logging.info("get redis_data:%s" % redis_data) # logging.info("get redis_data:%s" % redis_data)
values = list(redis_data.values()) # values = list(redis_data.values())
s = [True for i in values if i > 0] # s = [True for i in values if i > 0]
if len(s) > 0: # if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info)) # send_email_tome(str(redis_data) + str(card_info))
return True return True
except: 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