Commit 162a324a authored by lixiaofang's avatar lixiaofang

dd

parent 3864b9b2
......@@ -40,16 +40,18 @@ def click(card_info):
logging.info("get_card_info:%s,create_answer_vote:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True
if error == 0 and click_num <= 10:
return True, True
elif error == 0 and click_num > 10:
return True, False
else:
send_email_tome(str(card_info) + str(status))
return False
return False, False
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -47,14 +47,16 @@ def comment(card_info):
'comment_content']).unwrap()
logging.info("get_card_info:%s,have_answer_reply:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True
if error == 0 and comment_num <= 11:
return True, True
elif error == 0 and comment_num > 11:
return True, False
else:
send_email_tome(str(card_info) + str(status))
return False
return False, False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
elif card_info['card_status'] == 'diary':
today = datetime.datetime.now()
......@@ -129,15 +131,17 @@ def comment(card_info):
'comment_content']).unwrap()
logging.info("get_card_info:%s,have_answer_reply:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True
if error == 0 and comment_num <= 11:
return True, True
elif error == 0 and comment_num > 11:
return True, False
else:
send_email_tome(str(card_info) + str(status))
return False
return False, False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -38,17 +38,17 @@ def follow(card_info):
logging.info("get_card_info:%s,user_add_follow:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True
if error == 0 and follow_num <= 10:
return True, True
elif error == 0 and follow_num > 10:
return True, False
else:
send_email_tome(str(card_info) + str(status))
return False
return True
return False, False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -41,7 +41,8 @@ def kafka_consum(topic_name=None):
card_info = json.loads(str(msg.value, encoding="utf8"))
if card_info['card_type'] == "auto_vest":
###在这里去判断一下当前的partition和offset是否已经消费过了 如果已经消费了需要直接去掉数据
bol_consum = judge_offset_partition_have_consum(card_info=card_info,offset=msg.offset, partition=msg.partition)
bol_consum = judge_offset_partition_have_consum(card_info=card_info, offset=msg.offset,
partition=msg.partition)
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))
......@@ -99,14 +100,14 @@ def kafka_consum(topic_name=None):
if card_info['have_pust_num'] < card_info['need_pust_num'] and \
push_time_date < nowtime:
is_many = True
if action_type == "comment": # 在这里去调评论的接口
if 'have_comment_number' in card_info and \
card_info['have_comment_number'] < 20:
card_info["have_comment_number"] += 1
logging.info("当前卡片ID:%s,comment1子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
is_success = comment(card_info)
is_success, is_many = comment(card_info)
logging.info("comment [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset),
str(msg.key),
......@@ -114,31 +115,35 @@ def kafka_consum(topic_name=None):
logging.info("当前卡片ID:%s,comment2子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
# 调完接口后需要再次去拿新的push_time的时间
if is_many:
auto_comment_user(card_info)
elif action_type == "click": # 在这里去调点赞的接口
if 'have_click_number' in card_info and \
card_info['have_click_number'] < 20:
is_many = True
if 'have_click_number' in card_info:
card_info["have_click_number"] += 1
logging.info("当前卡片ID:%s,click1子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
is_success = click(card_info)
is_success, is_many = click(card_info)
logging.info("click [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset),
str(msg.key),
card_info["card_id"], is_success))
logging.info("当前卡片ID:%s,click2子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
if is_many:
auto_click_user(card_info)
elif action_type == "follow": # 在这里去调关注的接口
if 'have_follow_number' in card_info and \
card_info['have_follow_number'] < 20:
is_many = True
if 'have_follow_number' in card_info:
card_info["have_follow_number"] += 1
logging.info("当前卡片ID:%s,follow1子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
is_success = follow(card_info)
is_success, is_many = follow(card_info)
logging.info("当前卡片ID:%s,follow2子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
......@@ -147,6 +152,7 @@ def kafka_consum(topic_name=None):
str(msg.key),
card_info["card_id"], is_success))
if is_many == True:
auto_follow_user(card_info)
else: # push_time时间未到 需要等待
......
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