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
824f2643
Commit
824f2643
authored
Dec 31, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加日志
parent
66588259
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
14 deletions
+89
-14
auto_comment.py
comment/views/auto_comment.py
+1
-0
comment_fun.py
comment/views/comment_fun.py
+58
-1
auto_follow.py
follow/views/auto_follow.py
+1
-0
consum.py
moment/views/consum.py
+0
-1
irrigation.py
moment/views/irrigation.py
+29
-12
No files found.
comment/views/auto_comment.py
View file @
824f2643
...
@@ -13,6 +13,7 @@ logger = logging.getLogger(__name__)
...
@@ -13,6 +13,7 @@ logger = logging.getLogger(__name__)
def
auto_comment_user
(
card_info
,
after_day
=
False
):
def
auto_comment_user
(
card_info
,
after_day
=
False
):
"""
"""
帖子回答日记都是一样的下发策略
当天发布之后
当天发布之后
2-4小时内随机,给予[0-1]个评论
2-4小时内随机,给予[0-1]个评论
...
...
comment/views/comment_fun.py
View file @
824f2643
...
@@ -8,7 +8,15 @@ from moment.views.send_email import send_email_tome
...
@@ -8,7 +8,15 @@ from moment.views.send_email import send_email_tome
def
comment
(
card_info
):
def
comment
(
card_info
):
"""
在这个地方需要区分卡片的类型去调用不同的接口
:param card_info:
:return:
"""
try
:
try
:
rpc_invoker
=
get_rpc_invoker
()
##如果是回答
if
card_info
[
'type_status'
]
==
'answer'
:
key
=
"auto_vest_one_user_action:"
+
str
(
card_info
[
'card_id'
])
key
=
"auto_vest_one_user_action:"
+
str
(
card_info
[
'card_id'
])
redis_data
=
redis_client
.
get
(
key
)
redis_data
=
redis_client
.
get
(
key
)
if
redis_data
:
if
redis_data
:
...
@@ -20,16 +28,65 @@ def comment(card_info):
...
@@ -20,16 +28,65 @@ def comment(card_info):
redis_data
=
{
"click"
:
0
,
"follow"
:
0
,
"comment"
:
1
}
redis_data
=
{
"click"
:
0
,
"follow"
:
0
,
"comment"
:
1
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get action:comment,card_id:
%
s,redis_data:
%
s"
%
(
card_info
[
'card_id'
],
redis_data
))
logging
.
info
(
"get action:comment,card_id:
%
s,redis_data:
%
s"
%
(
card_info
[
'card_id'
],
redis_data
))
comment_num
=
redis_data
[
"comment"
]
comment_num
=
redis_data
[
"comment"
]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if
comment_num
>
20
:
if
comment_num
>
20
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
else
:
else
:
rpc_invoker
=
get_rpc_invoker
()
rpc_invoker
[
'qa/irrigation/create_answer_reply'
](
user_id
=
card_info
[
'current_user_id'
],
rpc_invoker
[
'qa/irrigation/create_answer_reply'
](
user_id
=
card_info
[
'current_user_id'
],
answer_id
=
card_info
[
'card_id'
],
answer_id
=
card_info
[
'card_id'
],
content
=
card_info
[
'comment_content'
])
.
unwrap
()
content
=
card_info
[
'comment_content'
])
.
unwrap
()
if
card_info
[
'type_status'
]
==
'tractate'
:
key
=
"auto_vest_one_user_action_tractate:"
+
str
(
card_info
[
'card_id'
])
redis_data
=
redis_client
.
get
(
key
)
if
redis_data
:
redis_data
=
json
.
loads
(
redis_data
)
click_num
=
int
(
redis_data
.
get
(
"comment"
))
+
1
redis_data
[
'comment'
]
=
click_num
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
else
:
redis_data
=
{
"comment"
:
1
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get action:comment,card_id:
%
s,redis_data:
%
s"
%
(
card_info
[
'card_id'
],
redis_data
))
comment_num
=
redis_data
[
"comment"
]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if
comment_num
>
20
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
else
:
rpc_invoker
[
'qa/irrigation/create_tractate_reply'
](
user_id
=
card_info
[
'current_user_id'
],
answer_id
=
card_info
[
'card_id'
],
content
=
card_info
[
'comment_content'
])
.
unwrap
()
if
card_info
[
'type_status'
]
==
'diary'
:
key
=
"auto_vest_one_user_action_diary:"
+
str
(
card_info
[
'card_id'
])
redis_data
=
redis_client
.
get
(
key
)
if
redis_data
:
redis_data
=
json
.
loads
(
redis_data
)
click_num
=
int
(
redis_data
.
get
(
"comment"
))
+
1
redis_data
[
'comment'
]
=
click_num
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
else
:
redis_data
=
{
"comment"
:
1
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get action:comment,card_id:
%
s,redis_data:
%
s"
%
(
card_info
[
'card_id'
],
redis_data
))
comment_num
=
redis_data
[
"comment"
]
####在这里做判断 一天不能超过20个 如果超过二十个不下发 不超过二十个下发对应的灌水功能
if
comment_num
>
20
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
else
:
rpc_invoker
[
'qa/irrigation/create_diary_reply'
](
user_id
=
card_info
[
'current_user_id'
],
answer_id
=
card_info
[
'card_id'
],
content
=
card_info
[
'comment_content'
])
.
unwrap
()
return
True
return
True
except
:
except
:
logging_exception
()
logging_exception
()
...
...
follow/views/auto_follow.py
View file @
824f2643
...
@@ -92,6 +92,7 @@ def auto_follow_user(card_info, after_day=False):
...
@@ -92,6 +92,7 @@ def auto_follow_user(card_info, after_day=False):
if
len
(
card_info
[
"all_follow_id"
])
>
0
:
if
len
(
card_info
[
"all_follow_id"
])
>
0
:
card_info
[
'current_push_time'
]
=
card_info
[
'all_push_time'
][
0
]
card_info
[
'current_push_time'
]
=
card_info
[
'all_push_time'
][
0
]
logging
.
info
(
"get-------comment---------------card_info:
%
s"
%
card_info
)
save_data_to_kafka
(
card_info
)
# 存储数据
save_data_to_kafka
(
card_info
)
# 存储数据
except
:
except
:
...
...
moment/views/consum.py
View file @
824f2643
...
@@ -134,7 +134,6 @@ def kafka_consum(topic_name=None):
...
@@ -134,7 +134,6 @@ def kafka_consum(topic_name=None):
is_success
=
follow
(
card_info
)
is_success
=
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
))
logging
.
info
(
"follow [
%
s,
%
s,
%
s,
%
s],当前ID:
%
s,下发状状态:
%
s"
%
(
logging
.
info
(
"follow [
%
s,
%
s,
%
s,
%
s],当前ID:
%
s,下发状状态:
%
s"
%
(
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
str
(
msg
.
topic
),
str
(
msg
.
partition
),
str
(
msg
.
offset
),
str
(
msg
.
key
),
card_info
[
"card_id"
],
is_success
))
card_info
[
"card_id"
],
is_success
))
...
...
moment/views/irrigation.py
View file @
824f2643
...
@@ -14,6 +14,16 @@ from libs.error import logging_exception
...
@@ -14,6 +14,16 @@ from libs.error import logging_exception
@bind
(
'vest/moment/vest_irrigation'
)
@bind
(
'vest/moment/vest_irrigation'
)
def
vest_irrigation
(
card_id
=
0
,
card_type
=
None
,
card_user_id
=
None
,
create_time
=
""
,
content_level
=
0
,
tag_names
=
[]):
def
vest_irrigation
(
card_id
=
0
,
card_type
=
None
,
card_user_id
=
None
,
create_time
=
""
,
content_level
=
0
,
tag_names
=
[]):
'''
帖子回答日记都有评论灌水 回答有点赞和关注
:param card_id:
:param card_type:
:param card_user_id:
:param create_time:
:param content_level:
:param tag_names:
:return:
'''
try
:
try
:
producer
=
KafkaProducer
(
bootstrap_servers
=
settings
.
KAFKA_BROKER_LIST
)
producer
=
KafkaProducer
(
bootstrap_servers
=
settings
.
KAFKA_BROKER_LIST
)
...
@@ -28,47 +38,54 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
...
@@ -28,47 +38,54 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
if
i
in
tag_list
:
if
i
in
tag_list
:
flag
=
True
flag
=
True
if
flag
==
True
:
if
card_type
==
'answer'
:
comment_msg_dict
=
{
###关注
follow_msg_dict
=
{
"card_id"
:
card_id
,
"card_id"
:
card_id
,
'type_status'
:
card_type
,
"card_type"
:
"auto_vest"
,
"card_type"
:
"auto_vest"
,
"create_time"
:
create_time
,
"create_time"
:
create_time
,
"content_level"
:
content_level
,
"content_level"
:
content_level
,
"tag_names"
:
tag_names
,
"tag_names"
:
tag_names
,
"type"
:
"get_write_answer_userinfo"
,
"type"
:
"get_write_answer_userinfo"
,
"current_push_time"
:
create_time
,
"current_push_time"
:
create_time
,
'action_type'
:
'comment'
'action_type'
:
'follow'
,
'card_user_id'
:
card_user_id
}
}
logging
.
info
(
"get comment_msg_dict:
%
s"
%
comment_msg_dict
)
producer
.
send
(
topic
,
json
.
dumps
(
follow_msg_dict
)
.
encode
())
producer
.
send
(
topic
,
json
.
dumps
(
comment_msg_dict
)
.
encode
())
follow_msg_dict
=
{
##点赞
click_msg_dict
=
{
"card_id"
:
card_id
,
"card_id"
:
card_id
,
'type_status'
:
card_type
,
"card_type"
:
"auto_vest"
,
"card_type"
:
"auto_vest"
,
"create_time"
:
create_time
,
"create_time"
:
create_time
,
"content_level"
:
content_level
,
"content_level"
:
content_level
,
"tag_names"
:
tag_names
,
"tag_names"
:
tag_names
,
"type"
:
"get_write_answer_userinfo"
,
"type"
:
"get_write_answer_userinfo"
,
"current_push_time"
:
create_time
,
"current_push_time"
:
create_time
,
'action_type'
:
'follow'
,
'action_type'
:
'click'
'card_user_id'
:
card_user_id
}
}
producer
.
send
(
topic
,
json
.
dumps
(
follow
_msg_dict
)
.
encode
())
producer
.
send
(
topic
,
json
.
dumps
(
click
_msg_dict
)
.
encode
())
click_msg_dict
=
{
##当有对应的标签的时候才下发评论
if
flag
==
True
:
comment_msg_dict
=
{
"card_id"
:
card_id
,
"card_id"
:
card_id
,
'type_status'
:
card_type
,
"card_type"
:
"auto_vest"
,
"card_type"
:
"auto_vest"
,
"create_time"
:
create_time
,
"create_time"
:
create_time
,
"content_level"
:
content_level
,
"content_level"
:
content_level
,
"tag_names"
:
tag_names
,
"tag_names"
:
tag_names
,
"type"
:
"get_write_answer_userinfo"
,
"type"
:
"get_write_answer_userinfo"
,
"current_push_time"
:
create_time
,
"current_push_time"
:
create_time
,
'action_type'
:
'click
'
'action_type'
:
'comment
'
}
}
producer
.
send
(
topic
,
json
.
dumps
(
click_msg_dict
)
.
encode
())
logging
.
info
(
"get comment_msg_dict:
%
s"
%
comment_msg_dict
)
producer
.
send
(
topic
,
json
.
dumps
(
comment_msg_dict
)
.
encode
())
producer
.
close
()
producer
.
close
()
...
...
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