Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
V
vest
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
vest
Commits
deceedbe
Commit
deceedbe
authored
Jan 10, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
69859c8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
consum.py
moment/views/consum.py
+2
-2
process_time.py
moment/views/process_time.py
+10
-0
No files found.
moment/views/consum.py
View file @
deceedbe
...
@@ -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
=
5
0
)
msg_dict
=
consumser_obj
.
poll
(
timeout_ms
=
100
0
,
max_records
=
10
0
)
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"
%
(
...
...
moment/views/process_time.py
View file @
deceedbe
...
@@ -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'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment