Commit deceedbe authored by lixiaofang's avatar lixiaofang

add

parent 69859c8a
...@@ -35,7 +35,7 @@ def kafka_consum(topic_name=None): ...@@ -35,7 +35,7 @@ def kafka_consum(topic_name=None):
# consumser_obj.seek(partition=TopicPartition(topic_name,int(partition_id.decode())),offset=int(topic_partition_info[partition_id])) # consumser_obj.seek(partition=TopicPartition(topic_name,int(partition_id.decode())),offset=int(topic_partition_info[partition_id]))
while True: while True:
begin = time.time() begin = time.time()
msg_dict = consumser_obj.poll(timeout_ms=100, max_records=50) msg_dict = consumser_obj.poll(timeout_ms=1000, max_records=100)
for msg_value in msg_dict.values(): for msg_value in msg_dict.values():
for msg in msg_value: for msg in msg_value:
card_info = json.loads(str(msg.value, encoding="utf8")) card_info = json.loads(str(msg.value, encoding="utf8"))
...@@ -44,7 +44,7 @@ def kafka_consum(topic_name=None): ...@@ -44,7 +44,7 @@ def kafka_consum(topic_name=None):
# bol_consum = judge_offset_partition_have_consum(card_info=card_info, offset=msg.offset, # bol_consum = judge_offset_partition_have_consum(card_info=card_info, offset=msg.offset,
# partition=msg.partition) # partition=msg.partition)
##在这里先判断当前的数据是否已经存在,存在的话直接PaaS,不存在的话再做下边的处理 ##在这里先判断当前的数据是否已经存在,存在的话直接PaaS,不存在的话再做下边的处理
# bol_consum = judge_data_have_in_redis(card_info) bol_consum = judge_data_have_in_redis(card_info)
bol_consum = True bol_consum = True
if bol_consum: if bol_consum:
logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % ( logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % (
......
...@@ -369,6 +369,16 @@ def judge_offset_partition_have_consum(card_info=None, offset=0, partition=0): ...@@ -369,6 +369,16 @@ def judge_offset_partition_have_consum(card_info=None, offset=0, partition=0):
def judge_data_have_in_redis(card_info=None): def judge_data_have_in_redis(card_info=None):
try: try:
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
push_time = card_info['current_push_time']
push_datetime = datetime.datetime.strptime(push_time, '%Y-%m-%d %H:%M:%S')
str_push_datetime = str(push_datetime.year) + str(push_datetime.month) + str(push_datetime.day)
if str_today != str_push_datetime:
return True
if card_info['action_type'] == 'comment': if card_info['action_type'] == 'comment':
##在这里加一个判断 如果当前的评论的user_id和评论内容已经在这个评论下了就不再下发给同一个回答ID ##在这里加一个判断 如果当前的评论的user_id和评论内容已经在这个评论下了就不再下发给同一个回答ID
key = 'have_reply_answer_comment:' + str(card_info['card_id']) key = 'have_reply_answer_comment:' + str(card_info['card_id'])
......
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