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
13664561
Commit
13664561
authored
Aug 30, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag
parent
71d8e15d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
13 deletions
+39
-13
group.py
search/views/group.py
+5
-0
tag.py
search/views/tag.py
+0
-0
topic.py
search/views/topic.py
+23
-13
tag.py
trans2es/models/tag.py
+11
-0
No files found.
search/views/group.py
View file @
13664561
...
...
@@ -17,6 +17,7 @@ from trans2es.models.topic import CommunityCategoryTagRelation
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.pictorial
import
CommunityPictorialActivity
from
alpha_types.venus
import
PICTORIAL_ACTIVITY_SORT
from
search.views.tag
import
get_same_tagset_ids
@bind
(
"physical/search/query_pictorial"
)
...
...
@@ -148,6 +149,10 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
for
item
in
result_dict
[
"hits"
]:
pict_pictorial_ids_list
=
item
[
"_source"
][
"pictorial_id"
]
topic_tag_list
=
item
[
"_source"
][
"tag_list"
]
##拿到这些标签的同义词
topic_tag_list
=
get_same_tagset_ids
(
topic_tag_list
)
##先拿到当前帖子对应的标签的分类ID
tag_type_ids
=
CommunityCategoryTagRelation
.
objects
.
filter
(
tag_id__in
=
topic_tag_list
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
...
...
search/views/tag.py
View file @
13664561
This diff is collapsed.
Click to expand it.
search/views/topic.py
View file @
13664561
...
...
@@ -16,6 +16,7 @@ from django.conf import settings
from
libs.tools
import
get_have_read_lin_pictorial_id_list
import
datetime
from
trans2es.models.tag
import
Tag
from
search.views.tag
import
get_same_tagset_ids
def
get_discover_page_topic_ids
(
user_id
,
device_id
,
size
,
query_type
=
TopicPageType
.
FIND_PAGE
):
...
...
@@ -32,7 +33,8 @@ def get_discover_page_topic_ids(user_id, device_id, size, query_type=TopicPageTy
if
have_read_topic_id_list
==
None
:
have_read_topic_id_list
=
list
()
recommend_topic_ids
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
0
,
offset
=
0
,
size
=
size
,
recommend_topic_ids
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
0
,
offset
=
0
,
size
=
size
,
single_size
=
size
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
...
...
@@ -165,11 +167,13 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
rank_topic_id_list
=
list
()
ret_data_list
=
list
()
if
size
>
0
:
rank_topic_id_list
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
0
,
size
=
size
,
rank_topic_id_list
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
0
,
size
=
size
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
index_type
=
index_type
,
routing
=
topic_star_routing
,
index_type
=
index_type
,
routing
=
topic_star_routing
,
attention_tag_list
=
attention_tag_list
,
linucb_user_id_list
=
recommend_topic_user_list
,
disable_collpase
=
disable_collpase
)
...
...
@@ -202,7 +206,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
today
=
datetime
.
datetime
.
strptime
(
str
(
datetime
.
date
.
today
()),
"
%
Y-
%
m-
%
d"
)
tomorrow
=
today
+
datetime
.
timedelta
(
days
=
1
)
nowTime
=
datetime
.
datetime
.
now
()
expire_time
=
(
tomorrow
-
nowTime
)
.
seconds
+
3
*
60
*
60
expire_time
=
(
tomorrow
-
nowTime
)
.
seconds
+
3
*
60
*
60
redis_client
.
expire
(
redis_key
,
expire_time
)
ret_list
=
rank_topic_id_list
if
query
is
None
else
ret_data_list
...
...
@@ -217,10 +221,12 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
else
:
return
[],
[]
def
get_home_recommend_pictorial_ids
(
user_id
=-
1
,
device_id
=
""
,
size
=
4
):
def
get_home_recommend_pictorial_ids
(
user_id
=-
1
,
device_id
=
""
,
size
=
4
):
try
:
pictorial_recommend_redis_key
=
"physical:linucb:pictorial_recommend:device_id:"
+
str
(
device_id
)
have_read_lin_pictorial_id_list
=
get_have_read_lin_pictorial_id_list
(
device_id
,
user_id
,
TopicPageType
.
HOME_RECOMMEND
)
have_read_lin_pictorial_id_list
=
get_have_read_lin_pictorial_id_list
(
device_id
,
user_id
,
TopicPageType
.
HOME_RECOMMEND
)
pictorial_recommend_dict
=
redis_client
.
hgetall
(
pictorial_recommend_redis_key
)
pictorial_recommend_list
=
list
()
if
b
"data"
in
pictorial_recommend_dict
:
...
...
@@ -238,7 +244,7 @@ def get_home_recommend_pictorial_ids(user_id=-1,device_id="",size=4):
redis_key
=
"physical:home_pictorial_recommend"
+
":device_id:"
+
str
(
device_id
)
+
":query_type:"
+
str
(
TopicPageType
.
HOME_RECOMMEND
)
redis_field_list
=
'have_read_pictorial_list'
redis_client
.
hset
(
redis_key
,
redis_field_list
,
have_read_lin_pictorial_id_list
)
redis_client
.
hset
(
redis_key
,
redis_field_list
,
have_read_lin_pictorial_id_list
)
today
=
datetime
.
datetime
.
strptime
(
str
(
datetime
.
date
.
today
()),
"
%
Y-
%
m-
%
d"
)
tomorrow
=
today
+
datetime
.
timedelta
(
days
=
1
)
nowTime
=
datetime
.
datetime
.
now
()
...
...
@@ -313,7 +319,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=Topic
usefulrecall
=
usefulrecall
,
useful_tag_list
=
useful_tag_list
)
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
"useful_topic_ids"
:
useful_topic_ids
,
"linucb_pictorial_ids"
:
recommend_pictorial_ids
}
"useful_topic_ids"
:
useful_topic_ids
,
"linucb_pictorial_ids"
:
recommend_pictorial_ids
}
else
:
recommend_pictorial_ids
=
get_home_recommend_pictorial_ids
(
user_id
,
device_id
,
4
)
size
=
size
-
len
(
recommend_pictorial_ids
)
...
...
@@ -322,13 +328,14 @@ def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=Topic
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
)
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
"linucb_pictorial_ids"
:
recommend_pictorial_ids
}
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
"linucb_pictorial_ids"
:
recommend_pictorial_ids
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
if
usefulrecall
!=
-
1
:
return
{
"linucb_topic_ids"
:
[],
"rank_topic_ids"
:
[],
"useful_topic_ids"
:
[],
"linucb_pictorial_ids"
:
[]}
return
{
"linucb_topic_ids"
:
[],
"rank_topic_ids"
:
[],
"useful_topic_ids"
:
[],
"linucb_pictorial_ids"
:
[]}
else
:
return
{
"linucb_topic_ids"
:
[],
"rank_topic_ids"
:
[],
"linucb_pictorial_ids"
:
[]}
return
{
"linucb_topic_ids"
:
[],
"rank_topic_ids"
:
[],
"linucb_pictorial_ids"
:
[]}
@bind
(
"physical/search/discover_page"
)
...
...
@@ -434,6 +441,7 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
normal_tag_result
=
list
()
category_tag_reuslt
=
list
()
result
=
list
()
topic_tag_list
=
get_same_tagset_ids
(
topic_tag_list
)
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
topic_tag_list
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"id"
,
"is_category"
)
...
...
@@ -589,9 +597,11 @@ def query_topic_by_user_similarity(topic_similarity_score_dict, offset=0, size=1
try
:
must_topic_id_list
=
list
(
topic_similarity_score_dict
.
keys
())
topic_id_list
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
tag_id
=
0
,
user_id
=-
1
,
offset
=
offset
,
size
=
size
,
topic_id_list
,
ret_data_list
=
TopicUtils
.
get_recommend_topic_ids
(
tag_id
=
0
,
user_id
=-
1
,
offset
=
offset
,
size
=
size
,
single_size
=
size
,
must_topic_id_list
=
must_topic_id_list
,
index_type
=
"topic"
,
must_topic_id_list
=
must_topic_id_list
,
index_type
=
"topic"
,
routing
=
"4,5,6"
)
return
{
"recommend_topic_ids"
:
topic_id_list
}
...
...
trans2es/models/tag.py
View file @
13664561
...
...
@@ -107,4 +107,15 @@ class SettingsConfig(models.Model):
key
=
models
.
IntegerField
(
verbose_name
=
u"值"
)
val
=
models
.
IntegerField
(
verbose_name
=
"标签内容"
)
class
CommunityTagSetRelation
(
models
.
Model
):
class
Meta
:
verbose_name
=
"搜索热词"
db_table
=
"community_tag_set_relation"
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
tag_id
=
models
.
IntegerField
(
verbose_name
=
u"标签ID"
)
tag_set_id
=
models
.
IntegerField
(
verbose_name
=
u"标签ID"
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u"是否删除"
)
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