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
79ecf29a
Commit
79ecf29a
authored
Apr 16, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.wanmeizhensuo.com:alpha/physical
parents
1caa9200
ae984dff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
34 deletions
+50
-34
Project.xml
.idea/codeStyles/Project.xml
+0
-25
collect_data.py
linucb/views/collect_data.py
+4
-0
group.py
search/utils/group.py
+1
-2
group.py
search/views/group.py
+4
-3
topic.py
search/views/topic.py
+31
-4
topic.py
trans2es/models/topic.py
+10
-0
No files found.
.idea/codeStyles/Project.xml
View file @
79ecf29a
...
...
@@ -24,29 +24,5 @@
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
/>
</DBN-PSQL>
<DBN-SQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
>
<option
name=
"STATEMENT_SPACING"
value=
"one_line"
/>
<option
name=
"CLAUSE_CHOP_DOWN"
value=
"chop_down_if_statement_long"
/>
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
linucb/views/collect_data.py
View file @
79ecf29a
...
...
@@ -8,6 +8,7 @@ import logging
from
linucb.views.linucb
import
LinUCB
import
json
from
trans2es.models.tag
import
TopicTag
,
Tag
from
trans2es.models.topic
import
TopicHomeRecommend
import
traceback
from
django.conf
import
settings
from
libs.es
import
ESPerform
...
...
@@ -72,6 +73,9 @@ class CollectData(object):
redis_client
.
expire
(
tag_recommend_redis_key
,
7
*
24
*
60
*
60
)
have_read_topic_id_list
=
Tools
.
get_have_read_topic_id_list
(
device_id
,
-
1
,
TopicPageType
.
HOME_RECOMMEND
)
promote_recommend_topic_id_list
=
list
()
promote_recommend_topic_id_list
=
TopicHomeRecommend
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_online
=
1
)
.
values_list
(
"topic_id"
)
have_read_topic_id_list
.
extend
(
promote_recommend_topic_id_list
)
recommend_topic_id_list
=
list
()
recommend_topic_id_list_click
=
list
()
...
...
search/utils/group.py
View file @
79ecf29a
...
...
@@ -63,8 +63,7 @@ class GroupUtils(object):
}
}
q
[
"sort"
]
=
[
{
"high_quality_topic_num"
:{
"order"
:
"desc"
}},
{
"create_time"
:{
"order"
:
"desc"
}}
{
"high_quality_topic_num"
:{
"order"
:
"desc"
}}
]
q
[
"_source"
]
=
{
"includes"
:[
"id"
]
...
...
search/views/group.py
View file @
79ecf29a
...
...
@@ -224,9 +224,10 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
]
}
},
"sort"
:{
"total_vote_num"
:{
"order"
:
"desc"
}
}
"sort"
:[
{
"total_vote_num"
:{
"order"
:
"desc"
}},
{
"create_time"
:
{
"order"
:
"desc"
}}
]
}
pict_pictorial_ids_list
=
[]
# 获取es链接对象
...
...
search/views/topic.py
View file @
79ecf29a
...
...
@@ -7,10 +7,13 @@ import logging
import
traceback
import
json
from
search.utils.topic
import
TopicUtils
from
trans2es.models.topic
import
TopicHomeRecommend
from
libs.es
import
ESPerform
from
libs.cache
import
redis_client
from
search.utils.common
import
*
from
libs.es
import
ESPerform
from
django.conf
import
settings
def
get_discover_page_topic_ids
(
user_id
,
device_id
,
size
,
query_type
=
TopicPageType
.
FIND_PAGE
):
...
...
@@ -74,7 +77,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
if
b
"data"
in
recommend_topic_dict
:
recommend_topic_id_list
=
json
.
loads
(
recommend_topic_dict
[
b
"data"
])
cursor
=
int
(
str
(
recommend_topic_dict
[
b
"cursor"
],
encoding
=
"utf-8"
))
newcursor
=
cursor
+
5
newcursor
=
cursor
+
6
if
len
(
recommend_topic_id_list
)
>
newcursor
:
recommend_topic_list
=
recommend_topic_id_list
[
cursor
:
newcursor
]
redis_client
.
hset
(
topic_recommend_redis_key
,
"cursor"
,
newcursor
)
...
...
@@ -114,12 +117,36 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
if
len
(
recommend_topic_list
)
>
0
:
size
=
size
-
len
(
recommend_topic_list
)
have_read_topic_id_list
.
extend
(
recommend_topic_list
)
topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
,
have_read_topic_id_list_add_promote
=
list
()
have_read_topic_id_list_add_promote
.
extend
(
have_read_topic_id_list
)
# promote_recommend_topic_id_list = TopicHomeRecommend.objects.using(settings.SLAVE_DB_NAME).filter(
# is_online=1).values_list("topic_id")
# if len(have_read_topic_id_list)>0:
# for topic_id in promote_recommend_topic_id_list:
# have_read_topic_id_list_add_promote.extend(topic_id)
topic_id_list
=
list
()
rank_topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
filter_topic_id_list
=
have_read_topic_id_list
_add_promote
,
recommend_tag_list
=
recommend_topic_list
,
user_similar_score_list
=
user_similar_score_redis_list
,
index_type
=
"topic"
,
routing
=
"4,5"
,
attention_tag_list
=
attention_tag_list
)
if
(
len
(
recommend_topic_list
)
==
6
):
if
(
size
<
11
):
topic_id_list
.
extend
(
rank_topic_id_list
[
0
:
3
])
topic_id_list
.
extend
(
recommend_topic_id_list
[
0
:
3
])
topic_id_list
.
extend
(
rank_topic_id_list
[
3
:
size
])
topic_id_list
.
extend
(
recommend_topic_id_list
[
3
:
6
])
else
:
topic_id_list
.
extend
(
rank_topic_id_list
[
0
:
size
-
7
])
topic_id_list
.
extend
(
recommend_topic_id_list
[
0
:
3
])
topic_id_list
.
extend
(
rank_topic_id_list
[
size
-
7
:
size
])
topic_id_list
.
extend
(
recommend_topic_id_list
[
3
:
6
])
else
:
topic_id_list
.
extend
(
rank_topic_id_list
)
have_read_group_id_set
=
set
()
have_read_user_id_set
=
set
()
unread_topic_id_dict
=
dict
()
...
...
@@ -161,7 +188,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# else:
# break
topic_id_list
.
extend
(
recommend_topic_list
)
#
topic_id_list.extend(recommend_topic_list)
# recommend_topic_list.extend(topic_id_list)
have_read_topic_id_list
.
extend
(
topic_id_list
)
if
len
(
have_read_topic_id_list
)
>
30000
:
...
...
trans2es/models/topic.py
View file @
79ecf29a
...
...
@@ -281,3 +281,12 @@ class ExcellentTopic(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
TopicHomeRecommend
(
models
.
Model
):
"""运营位帖子"""
class
Meta
:
verbose_name
=
"运营位帖子"
db_table
=
"topic_home_recommend"
id
=
models
.
IntegerField
(
verbose_name
=
u"id"
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
\ No newline at end of file
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