Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
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
0
Merge Requests
0
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
alpha
physical
Commits
46910c56
Commit
46910c56
authored
Oct 13, 2019
by
谢祁峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' of git.wanmeizhensuo.com:alpha/physical into 20191013_xqf
parents
c869565f
1eb1f006
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
219 additions
and
6 deletions
+219
-6
Makefile
Makefile
+2
-0
README.md
README.md
+4
-5
tag.py
search/views/tag.py
+22
-0
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+5
-1
__init__.py
trans2es/models/__init__.py
+2
-0
account_reg_extra.py
trans2es/models/account_reg_extra.py
+20
-0
auto_click_per_1d_by_post.py
vest/click/auto_click_per_1d_by_post.py
+102
-0
auto_click_per_2h_by_post.py
vest/click/auto_click_per_2h_by_post.py
+62
-0
No files found.
Makefile
0 → 100644
View file @
46910c56
crontab
:
cp
crontab.py /data/log/physical/app/crontab.py
&&
python /data/log/physical/app/crontab.py
&&
python /data/log/physical/app/crontabs.py
README.md
View file @
46910c56
...
...
@@ -55,10 +55,10 @@ celery -A physical beat
### physical策略端脚本
在Alp-Test-Cos-test001服务器上,通过crontab -l查看
<<<<<<< README.md
更新脚本
```
bash
cp
crontab.py /data/log/physical/app/crontab.py
python /data/log/physical/app/crontab.py
python /data/log/physical/app/crontabs.py
```
\ No newline at end of file
make crontab
```
search/views/tag.py
View file @
46910c56
...
...
@@ -16,6 +16,7 @@ from trans2es.models.tag import CommunityTagSetRelation
from
django.conf
import
settings
from
libs.error
import
logging_exception
from
django.db
import
connection
from
trans2es.models.account_reg_extra
import
AccountRegExtra
def
get_highlight
(
fields
=
[]):
...
...
@@ -143,6 +144,27 @@ def choice_pictorial_push_tag(device_id, user_id):
return
{
"pictorial_tag_list"
:
[]}
@bind
(
"physical/search/lintag_by_user_id"
)
def
get_lintags_by_user_id
(
user_id
):
try
:
devices
=
AccountRegExtra
.
objects
.
filter
(
user_id
=
user_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"device_id"
,
flat
=
True
)
if
devices
:
linucb_recommend_redis_prefix
=
"physical:linucb:tag_recommend:device_id:"
device_id
=
devices
[
0
]
redis_key
=
linucb_recommend_redis_prefix
+
str
(
device_id
)
tag_data
=
redis_client
.
get
(
redis_key
)
lintags
=
[]
if
tag_data
is
None
:
lintags
=
[]
else
:
lintags
=
json
.
loads
(
str
(
tag_data
,
encoding
=
"utf-8"
))
return
{
"lin_tag_list"
:
lintags
[:
3
]}
return
{
"lin_tag_list"
:
[]}
except
Exception
as
e
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"lin_tag_list"
:
[]}
@bind
(
"physical/search/choice_push_tag"
)
def
choice_push_tag
(
device_id
,
user_id
):
"""
...
...
trans2es/management/commands/trans2es_mapping2es.py
View file @
46910c56
...
...
@@ -9,7 +9,7 @@ from libs.es import ESPerform
from
trans2es.type_info
import
get_type_info_map
,
TypeInfo
from
vest.reply
import
true_comment_one
,
true_comment_two
,
true_comment_three
,
one_seven_topic_comment
from
vest.click
import
true_click_five
,
true_click_two
,
true_click_four
,
true_click_one
,
true_click_three
,
\
one_seven_star_topic
one_seven_star_topic
,
auto_click_per_1d_by_post
,
auto_click_per_2h_by_post
from
vest.follow
import
auto_follow
,
auto_follow_new
,
auto_follow_per_5m_by_followed
,
\
auto_follow_per_1d_by_regist
,
auto_follow_per_1d_by_post
,
auto_follow_per_2h_by_post_and_regist
from
vest.urge
import
auto_star_urge
,
auto_lunch_app
,
auto_lunch_app2
,
auto_urge1
,
auto_urge2
...
...
@@ -87,6 +87,10 @@ class Command(BaseCommand):
true_click_five
.
true_click_five
()
if
options
[
"mvest"
]
==
"one_seven_star_topic"
:
one_seven_star_topic
.
one_seven_star_topic
()
if
options
[
"mvest"
]
==
"auto_click_per_1d_by_post"
:
auto_click_per_1d_by_post
.
auto_click_per_1d_by_post
()
if
options
[
"mvest"
]
==
"auto_click_per_2h_by_post"
:
auto_click_per_2h_by_post
.
auto_click_per_2h_by_post
()
# 评论
if
options
[
"mvest"
]
==
"true_comment_one"
:
...
...
trans2es/models/__init__.py
View file @
46910c56
...
...
@@ -14,3 +14,5 @@ from .user import User
from
.group
import
Group
from
.pictorial
import
PictorialFollow
from
.pictorial
import
Pictorial
from
.account_reg_extra
import
AccountRegExtra
trans2es/models/account_reg_extra.py
0 → 100644
View file @
46910c56
import
datetime
from
django.db
import
models
class
AccountRegExtra
(
models
.
Model
):
class
Meta
:
verbose_name
=
u"设备用户关系表"
db_table
=
"account_reg_extra"
id
=
models
.
IntegerField
(
verbose_name
=
"主键ID"
,
primary_key
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否上线"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u"创建时间"
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u"更新时间"
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u""
)
geo
=
models
.
CharField
(
verbose_name
=
u""
,
max_length
=
300
)
model
=
models
.
CharField
(
verbose_name
=
u""
,
max_length
=
64
)
device_id
=
models
.
CharField
(
verbose_name
=
u"设备ID"
,
max_length
=
64
)
share_code
=
models
.
CharField
(
verbose_name
=
u""
,
max_length
=
64
)
user_id
=
models
.
IntegerField
(
verbose_name
=
"用户ID"
)
vest/click/auto_click_per_1d_by_post.py
0 → 100644
View file @
46910c56
import
pymysql
import
random
import
traceback
import
logging
from
threading
import
Thread
from
vest.request.auto_request
import
login
,
time_convs
,
click
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
def
get_commnet_id
(
numtime
,
numtime2
,
content_level_low
=
0
,
content_level_top
=
6
):
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
cursor
.
execute
(
"select t.id from topic t left join user_extra u on t.user_id = u.user_id "
"where u.is_shadow=0 and t.create_time > '
%
s' and t.create_time < '
%
s' "
"and t.content_level >=
%
s and t.content_level <=
%
s "
%
(
numtime
,
numtime2
,
str
(
content_level_low
),
str
(
content_level_top
)))
res
=
cursor
.
fetchall
()
return
res
and
[
i
for
i
,
in
res
]
or
[]
def
batch_handle
(
auto_click_list
):
for
topic_id
in
auto_click_list
:
try
:
cookies
=
login
()
if
cookies
is
not
None
:
click
(
cookies
,
topic_id
)
except
:
pass
def
auto_click_per_1d_by_post
():
# 发帖触发自动点赞
auto_click_list
=
[]
try
:
# 1-3星及无星
# 1天前发的帖子:[2-6]个赞
numtime1
,
numtime2
=
time_convs
(
1
,
1
)
topic_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
0
,
content_level_top
=
3
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
2
,
6
)
for
i
in
range
(
click_num
):
auto_click_list
.
append
(
topic_id
)
# 2-15天前发的帖子:[0-2]个赞
numtime1
,
numtime2
=
time_convs
(
2
,
15
)
topic_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
0
,
content_level_top
=
3
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
0
,
2
)
for
i
in
range
(
click_num
):
auto_click_list
.
append
(
topic_id
)
# 15天前或更早发的帖子:每隔6天[0-1]个赞
numtime1
,
numtime2
=
time_convs
(
2
,
15
)
topic_ids
=
get_commnet_id
(
'0'
,
numtime2
,
content_level_low
=
0
,
content_level_top
=
3
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
1
,
6
)
if
click_num
==
6
:
auto_click_list
.
append
(
topic_id
)
# 4-6星帖
# 1天前发的帖子:[4-12]个赞
numtime1
,
numtime2
=
time_convs
(
1
,
1
)
topic_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
4
,
content_level_top
=
6
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
4
,
12
)
for
i
in
range
(
click_num
):
auto_click_list
.
append
(
topic_id
)
# 2-15天前发的帖子:[0-6]个赞
numtime1
,
numtime2
=
time_convs
(
2
,
15
)
topic_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
4
,
content_level_top
=
6
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
0
,
6
)
for
i
in
range
(
click_num
):
auto_click_list
.
append
(
topic_id
)
# 15天前或更早发的帖子:每隔5天[0-3]个赞
numtime1
,
numtime2
=
time_convs
(
2
,
15
)
topic_ids
=
get_commnet_id
(
'0'
,
numtime2
,
content_level_low
=
4
,
content_level_top
=
6
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
1
,
3
)
if
click_num
==
3
:
auto_click_list
.
append
(
topic_id
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
logging
.
info
(
'auto_click_per_1d_by_post: len
%
s'
%
len
(
auto_click_list
))
print
(
'auto_click_per_1d_by_post: len
%
s'
%
len
(
auto_click_list
))
total
=
len
(
auto_click_list
)
limit
=
(
total
+
10
)
//
10
for
start
in
range
(
0
,
total
,
limit
):
batch
=
auto_click_list
[
start
:
start
+
limit
]
t
=
Thread
(
target
=
batch_handle
,
args
=
[
batch
])
t
.
start
()
vest/click/auto_click_per_2h_by_post.py
0 → 100644
View file @
46910c56
import
pymysql
import
random
import
traceback
import
logging
from
threading
import
Thread
from
vest.request.auto_request
import
login
,
time_conv_hour
,
follow
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
def
get_commnet_id
(
numtime
,
numtime2
,
content_level_low
=
0
,
content_level_top
=
6
):
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
# 发贴后
cursor
.
execute
(
"select t.id from topic t left join user_extra u on t.user_id = u.user_id "
"where u.is_shadow=0 and t.create_time > '
%
s' and t.create_time < '
%
s' "
"and t.content_level >=
%
s and t.content_level <=
%
s "
%
(
numtime
,
numtime2
,
str
(
content_level_low
),
str
(
content_level_top
)))
res
=
cursor
.
fetchall
()
return
res
and
[
i
for
i
,
in
res
]
or
[]
def
batch_handle
(
auto_click_list
):
for
topic_id
in
auto_click_list
:
try
:
cookies
=
login
()
if
cookies
is
not
None
:
follow
(
cookies
,
topic_id
)
except
:
pass
def
auto_click_per_2h_by_post
():
# 发帖触发自动点赞
auto_click_list
=
[]
try
:
# 发帖2小时内:[1-3]个点赞
numtime1
,
numtime2
=
time_conv_hour
(
0
,
2
)
topic_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
0
,
content_level_top
=
6
)
for
topic_id
in
topic_ids
:
click_num
=
random
.
randint
(
1
,
3
)
for
i
in
range
(
click_num
):
auto_click_list
.
append
(
topic_id
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
logging
.
info
(
'auto_follow_per_2h_by_post_and_regist: len
%
s'
%
len
(
auto_click_list
))
print
(
'auto_follow_per_2h_by_post_and_regist: len
%
s'
%
len
(
auto_click_list
))
total
=
len
(
auto_click_list
)
limit
=
(
total
+
10
)
//
10
for
start
in
range
(
0
,
total
,
limit
):
batch
=
auto_click_list
[
start
:
start
+
limit
]
t
=
Thread
(
target
=
batch_handle
,
args
=
[
batch
])
t
.
start
()
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