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
162a324a
Commit
162a324a
authored
Jan 06, 2020
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dd
parent
3864b9b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
33 deletions
+45
-33
click_fun.py
click/views/click_fun.py
+7
-5
comment_fun.py
comment/views/comment_fun.py
+13
-9
follow_fun.py
follow/views/follow_fun.py
+7
-7
consum.py
moment/views/consum.py
+18
-12
No files found.
click/views/click_fun.py
View file @
162a324a
...
@@ -40,16 +40,18 @@ def click(card_info):
...
@@ -40,16 +40,18 @@ def click(card_info):
logging
.
info
(
"get_card_info:
%
s,create_answer_vote:
%
s"
%
(
card_info
,
status
))
logging
.
info
(
"get_card_info:
%
s,create_answer_vote:
%
s"
%
(
card_info
,
status
))
error
=
status
.
get
(
'error'
,
1
)
error
=
status
.
get
(
'error'
,
1
)
if
error
==
0
:
if
error
==
0
and
click_num
<=
10
:
return
True
return
True
,
True
elif
error
==
0
and
click_num
>
10
:
return
True
,
False
else
:
else
:
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
return
False
return
False
,
False
except
:
except
:
logging_exception
()
logging_exception
()
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
except
:
except
:
logging_exception
()
logging_exception
()
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
comment/views/comment_fun.py
View file @
162a324a
...
@@ -47,14 +47,16 @@ def comment(card_info):
...
@@ -47,14 +47,16 @@ def comment(card_info):
'comment_content'
])
.
unwrap
()
'comment_content'
])
.
unwrap
()
logging
.
info
(
"get_card_info:
%
s,have_answer_reply:
%
s"
%
(
card_info
,
status
))
logging
.
info
(
"get_card_info:
%
s,have_answer_reply:
%
s"
%
(
card_info
,
status
))
error
=
status
.
get
(
'error'
,
1
)
error
=
status
.
get
(
'error'
,
1
)
if
error
==
0
:
if
error
==
0
and
comment_num
<=
11
:
return
True
return
True
,
True
elif
error
==
0
and
comment_num
>
11
:
return
True
,
False
else
:
else
:
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
return
False
return
False
,
False
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
elif
card_info
[
'card_status'
]
==
'diary'
:
elif
card_info
[
'card_status'
]
==
'diary'
:
today
=
datetime
.
datetime
.
now
()
today
=
datetime
.
datetime
.
now
()
...
@@ -129,15 +131,17 @@ def comment(card_info):
...
@@ -129,15 +131,17 @@ def comment(card_info):
'comment_content'
])
.
unwrap
()
'comment_content'
])
.
unwrap
()
logging
.
info
(
"get_card_info:
%
s,have_answer_reply:
%
s"
%
(
card_info
,
status
))
logging
.
info
(
"get_card_info:
%
s,have_answer_reply:
%
s"
%
(
card_info
,
status
))
error
=
status
.
get
(
'error'
,
1
)
error
=
status
.
get
(
'error'
,
1
)
if
error
==
0
:
if
error
==
0
and
comment_num
<=
11
:
return
True
return
True
,
True
elif
error
==
0
and
comment_num
>
11
:
return
True
,
False
else
:
else
:
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
return
False
return
False
,
False
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
except
:
except
:
logging_exception
()
logging_exception
()
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
follow/views/follow_fun.py
View file @
162a324a
...
@@ -38,17 +38,17 @@ def follow(card_info):
...
@@ -38,17 +38,17 @@ def follow(card_info):
logging
.
info
(
"get_card_info:
%
s,user_add_follow:
%
s"
%
(
card_info
,
status
))
logging
.
info
(
"get_card_info:
%
s,user_add_follow:
%
s"
%
(
card_info
,
status
))
error
=
status
.
get
(
'error'
,
1
)
error
=
status
.
get
(
'error'
,
1
)
if
error
==
0
:
if
error
==
0
and
follow_num
<=
10
:
return
True
return
True
,
True
elif
error
==
0
and
follow_num
>
10
:
return
True
,
False
else
:
else
:
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
send_email_tome
(
str
(
card_info
)
+
str
(
status
))
return
False
return
False
,
False
return
True
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
except
:
except
:
logging_exception
()
logging_exception
()
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
False
,
False
moment/views/consum.py
View file @
162a324a
...
@@ -41,7 +41,8 @@ def kafka_consum(topic_name=None):
...
@@ -41,7 +41,8 @@ def kafka_consum(topic_name=None):
card_info
=
json
.
loads
(
str
(
msg
.
value
,
encoding
=
"utf8"
))
card_info
=
json
.
loads
(
str
(
msg
.
value
,
encoding
=
"utf8"
))
if
card_info
[
'card_type'
]
==
"auto_vest"
:
if
card_info
[
'card_type'
]
==
"auto_vest"
:
###在这里去判断一下当前的partition和offset是否已经消费过了 如果已经消费了需要直接去掉数据
###在这里去判断一下当前的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
:
if
bol_consum
:
logging
.
info
(
"消费到新数据了[
%
s,
%
s,
%
s,
%
s],get card_info:
%
s"
%
(
logging
.
info
(
"消费到新数据了[
%
s,
%
s,
%
s,
%
s],get card_info:
%
s"
%
(
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
card_info
))
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
card_info
))
...
@@ -99,14 +100,14 @@ def kafka_consum(topic_name=None):
...
@@ -99,14 +100,14 @@ def kafka_consum(topic_name=None):
if
card_info
[
'have_pust_num'
]
<
card_info
[
'need_pust_num'
]
and
\
if
card_info
[
'have_pust_num'
]
<
card_info
[
'need_pust_num'
]
and
\
push_time_date
<
nowtime
:
push_time_date
<
nowtime
:
is_many
=
True
if
action_type
==
"comment"
:
# 在这里去调评论的接口
if
action_type
==
"comment"
:
# 在这里去调评论的接口
if
'have_comment_number'
in
card_info
and
\
if
'have_comment_number'
in
card_info
and
\
card_info
[
'have_comment_number'
]
<
20
:
card_info
[
'have_comment_number'
]
<
20
:
card_info
[
"have_comment_number"
]
+=
1
card_info
[
"have_comment_number"
]
+=
1
logging
.
info
(
"当前卡片ID:
%
s,comment1子函数消费处理耗时:
%
f"
%
(
logging
.
info
(
"当前卡片ID:
%
s,comment1子函数消费处理耗时:
%
f"
%
(
card_info
[
'card_id'
],
time
.
time
()
-
begin
))
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"
%
(
logging
.
info
(
"comment [
%
s,
%
s,
%
s,
%
s],当前ID:
%
s,下发状状态:
%
s"
%
(
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
str
(
msg
.
key
),
...
@@ -114,31 +115,35 @@ def kafka_consum(topic_name=None):
...
@@ -114,31 +115,35 @@ def kafka_consum(topic_name=None):
logging
.
info
(
"当前卡片ID:
%
s,comment2子函数消费处理耗时:
%
f"
%
(
logging
.
info
(
"当前卡片ID:
%
s,comment2子函数消费处理耗时:
%
f"
%
(
card_info
[
'card_id'
],
time
.
time
()
-
begin
))
card_info
[
'card_id'
],
time
.
time
()
-
begin
))
# 调完接口后需要再次去拿新的push_time的时间
# 调完接口后需要再次去拿新的push_time的时间
auto_comment_user
(
card_info
)
if
is_many
:
auto_comment_user
(
card_info
)
elif
action_type
==
"click"
:
# 在这里去调点赞的接口
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
card_info
[
"have_click_number"
]
+=
1
logging
.
info
(
"当前卡片ID:
%
s,click1子函数消费处理耗时:
%
f"
%
(
logging
.
info
(
"当前卡片ID:
%
s,click1子函数消费处理耗时:
%
f"
%
(
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
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"
%
(
logging
.
info
(
"click [
%
s,
%
s,
%
s,
%
s],当前ID:
%
s,下发状状态:
%
s"
%
(
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
str
(
msg
.
key
),
card_info
[
"card_id"
],
is_success
))
card_info
[
"card_id"
],
is_success
))
logging
.
info
(
"当前卡片ID:
%
s,click2子函数消费处理耗时:
%
f"
%
(
logging
.
info
(
"当前卡片ID:
%
s,click2子函数消费处理耗时:
%
f"
%
(
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
auto_click_user
(
card_info
)
if
is_many
:
auto_click_user
(
card_info
)
elif
action_type
==
"follow"
:
# 在这里去调关注的接口
elif
action_type
==
"follow"
:
# 在这里去调关注的接口
i
f
'have_follow_number'
in
card_info
and
\
i
s_many
=
True
card_info
[
'have_follow_number'
]
<
20
:
if
'have_follow_number'
in
card_info
:
card_info
[
"have_follow_number"
]
+=
1
card_info
[
"have_follow_number"
]
+=
1
logging
.
info
(
"当前卡片ID:
%
s,follow1子函数消费处理耗时:
%
f"
%
(
logging
.
info
(
"当前卡片ID:
%
s,follow1子函数消费处理耗时:
%
f"
%
(
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
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"
%
(
logging
.
info
(
"当前卡片ID:
%
s,follow2子函数消费处理耗时:
%
f"
%
(
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
card_info
[
"card_id"
],
time
.
time
()
-
begin
))
...
@@ -147,7 +152,8 @@ def kafka_consum(topic_name=None):
...
@@ -147,7 +152,8 @@ def kafka_consum(topic_name=None):
str
(
msg
.
key
),
str
(
msg
.
key
),
card_info
[
"card_id"
],
is_success
))
card_info
[
"card_id"
],
is_success
))
auto_follow_user
(
card_info
)
if
is_many
==
True
:
auto_follow_user
(
card_info
)
else
:
# push_time时间未到 需要等待
else
:
# push_time时间未到 需要等待
logging
.
info
(
"follow [
%
s,
%
s,
%
s,
%
s],push_time未到,需要等待"
%
(
logging
.
info
(
"follow [
%
s,
%
s,
%
s,
%
s],push_time未到,需要等待"
%
(
...
...
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