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
7442a922
Commit
7442a922
authored
Dec 26, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto_vest
parent
5f40f1c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
53 deletions
+53
-53
click_fun.py
click/views/click_fun.py
+17
-17
comment_fun.py
comment/views/comment_fun.py
+19
-19
follow_fun.py
follow/views/follow_fun.py
+17
-17
No files found.
click/views/click_fun.py
View file @
7442a922
...
...
@@ -14,23 +14,23 @@ def click(card_info):
rpc_invoker
[
'qa/irrigation/create_answer_vote'
](
user_id
=
card_info
[
'current_user_id'
],
answer_id
=
card_info
[
'card_id'
])
.
unwrap
()
key
=
"auto_vest_one_user_action:"
+
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
(
"click"
))
+
1
redis_data
[
'click'
]
=
click_num
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
else
:
redis_data
=
{
"click"
:
1
,
"follow"
:
0
,
"comment"
:
0
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get redis_data:
%
s"
%
redis_data
)
values
=
list
(
redis_data
.
values
())
s
=
[
True
for
i
in
values
if
i
>
0
]
if
len
(
s
)
>
0
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
#
redis_data = redis_client.get(key)
#
if redis_data:
#
redis_data = json.loads(redis_data)
#
click_num = int(redis_data.get("click")) + 1
#
redis_data['click'] = click_num
#
redis_client.set(key, json.dumps(redis_data))
#
else:
#
redis_data = {"click": 1, "follow": 0, "comment": 0}
#
redis_client.set(key, json.dumps(redis_data))
#
redis_client.expire(key, time=24 * 60 * 60)
#
#
logging.info("get redis_data:%s" % redis_data)
#
#
values = list(redis_data.values())
#
s = [True for i in values if i > 0]
#
if len(s) > 0:
#
send_email_tome(str(redis_data) + str(card_info))
return
True
except
:
...
...
comment/views/comment_fun.py
View file @
7442a922
...
...
@@ -6,32 +6,32 @@ from libs.cache import redis_client
import
json
from
moment.views.send_email
import
send_email_tome
def
comment
(
card_info
):
try
:
rpc_invoker
=
get_rpc_invoker
()
rpc_invoker
[
'qa/irrigation/create_answer_reply'
](
user_id
=
card_info
[
'current_user_id'
],
answer_id
=
card_info
[
'card_id'
],
content
=
card_info
[
'comment_content'
])
.
unwrap
()
####
key
=
"auto_vest_one_user_action:"
+
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
=
{
"click"
:
0
,
"follow"
:
0
,
"comment"
:
1
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get redis_data:
%
s"
%
redis_data
)
values
=
list
(
redis_data
.
values
())
s
=
[
True
for
i
in
values
if
i
>
0
]
if
len
(
s
)
>
0
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
#
key = "auto_vest_one_user_action:" + 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 = {"click": 0, "follow": 0, "comment": 1}
#
redis_client.set(key, json.dumps(redis_data))
#
redis_client.expire(key, time=24 * 60 * 60)
#
#
logging.info("get redis_data:%s" % redis_data)
#
#
values = list(redis_data.values())
#
s = [True for i in values if i > 0]
#
if len(s) > 0:
#
send_email_tome(str(redis_data) + str(card_info))
return
True
except
:
...
...
follow/views/follow_fun.py
View file @
7442a922
...
...
@@ -13,23 +13,23 @@ def follow(card_info):
rpc_invoker
[
'api/irrigation/user_add_follow'
](
follow_user_id
=
card_info
[
'current_user_id'
],
followed_user_id
=
card_info
[
'card_user_id'
])
.
unwrap
()
key
=
"auto_vest_one_user_action:"
+
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
(
"follow"
))
+
1
redis_data
[
'follow'
]
=
click_num
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
else
:
redis_data
=
{
"click"
:
0
,
"follow"
:
1
,
"comment"
:
0
}
redis_client
.
set
(
key
,
json
.
dumps
(
redis_data
))
redis_client
.
expire
(
key
,
time
=
24
*
60
*
60
)
logging
.
info
(
"get redis_data:
%
s"
%
redis_data
)
values
=
list
(
redis_data
.
values
())
s
=
[
True
for
i
in
values
if
i
>
0
]
if
len
(
s
)
>
0
:
send_email_tome
(
str
(
redis_data
)
+
str
(
card_info
))
#
key = "auto_vest_one_user_action:" + 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("follow")) + 1
#
redis_data['follow'] = click_num
#
redis_client.set(key, json.dumps(redis_data))
#
else:
#
redis_data = {"click": 0, "follow": 1, "comment": 0}
#
redis_client.set(key, json.dumps(redis_data))
#
redis_client.expire(key, time=24 * 60 * 60)
#
#
logging.info("get redis_data:%s" % redis_data)
#
values = list(redis_data.values())
#
s = [True for i in values if i > 0]
#
if len(s) > 0:
#
send_email_tome(str(redis_data) + str(card_info))
return
True
except
:
...
...
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