Commit 5c799516 authored by lixiaofang's avatar lixiaofang

auto_vest

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