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
钟尚武
physical
Commits
e3b0207c
Commit
e3b0207c
authored
Aug 25, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try except sys.exit and change mysql slave
parent
4396340f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
collect_data.py
linucb/views/collect_data.py
+8
-6
linucb.py
linucb/views/linucb.py
+1
-1
No files found.
linucb/views/collect_data.py
View file @
e3b0207c
...
...
@@ -16,6 +16,7 @@ from search.utils.common import *
import
libs.tools
as
Tools
from
trans2es.models.pictorial
import
CommunityPictorialHomeFeed
from
libs.error
import
logging_exception
import
sys
class
KafkaManager
(
object
):
consumser_obj
=
None
...
...
@@ -77,8 +78,8 @@ class CollectData(object):
have_read_topic_id_list
=
Tools
.
get_have_read_topic_id_list
(
device_id
,
user_id
,
TopicPageType
.
HOME_RECOMMEND
)
have_read_lin_pictorial_id_list
=
Tools
.
get_have_read_lin_pictorial_id_list
(
device_id
,
user_id
,
TopicPageType
.
HOME_RECOMMEND
)
promote_recommend_topic_id_list
=
TopicHomeRecommend
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_online
=
1
)
.
values_list
(
"topic_id"
,
flat
=
True
)
promote_lin_pictorial_id_list
=
CommunityPictorialHomeFeed
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
promote_recommend_topic_id_list
=
TopicHomeRecommend
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
is_online
=
1
)
.
values_list
(
"topic_id"
,
flat
=
True
)
promote_lin_pictorial_id_list
=
CommunityPictorialHomeFeed
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
is_deleted
=
0
,
is_online
=
1
)
.
values_list
(
"pictorial_id"
,
flat
=
True
)
have_read_topic_id_list
.
extend
(
promote_recommend_topic_id_list
)
have_read_lin_pictorial_id_list
.
extend
(
promote_lin_pictorial_id_list
)
...
...
@@ -190,13 +191,13 @@ class CollectData(object):
# if collection and is_ai:
# click_topic_tag_list.append(id)
topic_tag_list
=
list
()
click_results
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
click_results
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
topic_id
=
topic_id
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
"is_collection"
)
for
tag_id
,
is_collection
in
click_results
:
# topic_tag_list.append(tag_id)
if
is_collection
:
topic_tag_list
.
append
(
tag_id
)
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
id__in
=
topic_tag_list
,
is_online
=
True
,
is_deleted
=
False
,
is_category
=
False
)
.
values_list
(
"id"
,
"is_ai"
)
for
id
,
is_ai
in
tag_query_results
:
...
...
@@ -211,7 +212,7 @@ class CollectData(object):
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
if
query_type
==
"do"
:
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
name
=
tag_name
,
is_online
=
True
,
is_deleted
=
False
,
is_category
=
False
)
.
values_list
(
"id"
,
flat
=
True
))
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
name
=
tag_name
,
is_online
=
True
,
is_deleted
=
False
,
is_category
=
False
)
.
values_list
(
"id"
,
flat
=
True
))
click_topic_tag_list
.
extend
(
tag_list
)
logging
.
info
(
"query tag attention,positive tag_list,device_id:
%
s,query_name:
%
s,tag_list:
%
s"
%
(
str
(
device_id
),
tag_name
,
str
(
click_topic_tag_list
)))
...
...
@@ -296,7 +297,7 @@ class CollectData(object):
# if len(exposure_sql_query_results)>0:
if
len
(
tagid_list
)
>
0
:
tag_query_results
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
tag_query_results
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
id__in
=
tagid_list
,
is_online
=
True
,
is_deleted
=
False
,
is_category
=
False
)
.
values_list
(
"id"
,
flat
=
True
))
is_click
=
1
...
...
@@ -319,4 +320,5 @@ class CollectData(object):
except
:
logging_exception
()
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
sys
.
exit
()
return
False
linucb/views/linucb.py
View file @
e3b0207c
...
...
@@ -29,7 +29,7 @@ class LinUCB:
cls
.
default_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
if
len
(
cls
.
default_tag_list
)
==
0
:
cls
.
default_tag_list
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_online
=
True
,
collection
=
1
)
.
values_list
(
"id"
,
flat
=
True
)[
0
:
100
]
cls
.
default_tag_list
=
Tag
.
objects
.
using
(
settings
.
SLAVE
1
_DB_NAME
)
.
filter
(
is_online
=
True
,
collection
=
1
)
.
values_list
(
"id"
,
flat
=
True
)[
0
:
100
]
return
cls
.
default_tag_list
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