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
bb60cf1c
Commit
bb60cf1c
authored
Jan 03, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
8510b7f4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
consum.py
moment/views/consum.py
+1
-2
process_time.py
moment/views/process_time.py
+8
-1
No files found.
moment/views/consum.py
View file @
bb60cf1c
...
...
@@ -41,8 +41,7 @@ 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
(
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
))
...
...
moment/views/process_time.py
View file @
bb60cf1c
...
...
@@ -329,7 +329,7 @@ def get_vest_userid_and_comment(need_comment_num=0, tag_names=[], card_id=0):
return
[]
def
judge_offset_partition_have_consum
(
offset
=
0
,
partition
=
0
):
def
judge_offset_partition_have_consum
(
card_info
=
None
,
offset
=
0
,
partition
=
0
):
"""
根据当前的offset和分区去判断数据是否已经被消费
:param offset:
...
...
@@ -337,6 +337,13 @@ def judge_offset_partition_have_consum(offset=0, partition=0):
:return:
"""
try
:
##先判断是不是2019-12-29的
create_time
=
card_info
[
'create_time'
]
datetime_create_time
=
datetime
.
datetime
.
strptime
(
create_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
str_data
=
str
(
datetime_create_time
.
year
)
+
str
(
datetime_create_time
.
month
)
+
str
(
datetime_create_time
.
day
)
if
str_data
in
[
'20191229'
,
'20191230'
]:
return
False
redis_list_data
=
0
key
=
"irrigation_partition_offset_have_consum:"
+
str
(
partition
)
redis_data
=
redis_client
.
get
(
key
)
...
...
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