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
f4fea10d
Commit
f4fea10d
authored
Apr 28, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'test'
Master See merge request
!306
parents
f90de1e8
4f0b28b4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
85 deletions
+65
-85
Project.xml
.idea/codeStyles/Project.xml
+0
-25
es.py
libs/es.py
+29
-14
collect_data.py
linucb/views/collect_data.py
+3
-8
topic.py
search/utils/topic.py
+17
-21
tag.py
search/views/tag.py
+3
-3
topic.py
search/views/topic.py
+5
-6
topic.py
trans2es/models/topic.py
+8
-8
No files found.
.idea/codeStyles/Project.xml
View file @
f4fea10d
...
...
@@ -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
libs/es.py
View file @
f4fea10d
...
...
@@ -288,25 +288,40 @@ class ESPerform(object):
def
get_tag_topic_list
(
cls
,
tag_id
,
have_read_topic_id_list
,
size
=
100
):
try
:
functions_list
=
list
()
for
id
in
tag_id
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"tag_list"
:
id
}},
"weight"
:
1
}
)
#
for id in tag_id:
#
functions_list.append(
#
{
#
"filter": {"term": {"tag_list": id}},
#
"weight": 1
#
}
#
)
functions_list
+=
[
{
"filter"
:
{
"term"
:
{
"content_level"
:
6
}},
"weight"
:
6000
"filter"
:
{
"constant_score"
:{
"filter"
:{
"term"
:
{
"content_level"
:
6
}}
}
},
"weight"
:
60
},
{
"filter"
:
{
"term"
:
{
"content_level"
:
5
}},
"weight"
:
5000
"filter"
:
{
"constant_score"
:{
"filter"
:{
"term"
:
{
"content_level"
:
5
}}
}
},
"weight"
:
50
},
{
"filter"
:
{
"term"
:
{
"content_level"
:
4
}},
"weight"
:
4000
"filter"
:
{
"constant_score"
:{
"filter"
:{
"term"
:
{
"content_level"
:
4
}}
}
},
"weight"
:
40
}
]
q
=
{
...
...
@@ -333,7 +348,7 @@ class ESPerform(object):
"sort"
:
[
{
"_score"
:
{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
{
"language_type"
:
{
"order"
:
"asc"
}},
#
{"language_type": {"order": "asc"}},
]
}
if
len
(
have_read_topic_id_list
)
>
0
:
...
...
linucb/views/collect_data.py
View file @
f4fea10d
...
...
@@ -103,12 +103,9 @@ class CollectData(object):
if
len
(
recommend_topic_id_list
)
==
0
and
cursor
==
0
and
len
(
redis_topic_list
)
>
0
:
have_read_topic_id_list
.
extend
(
redis_topic_list
[:
2
])
if
len
(
tag_id_list
)
>
0
:
if
len
(
new_user_click_tag_list
)
>
0
:
if
len
(
new_user_click_tag_list
)
>
0
:
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
new_user_click_tag_list
,
have_read_topic_id_list
)
logging
.
warning
(
"tag_topic_id_list:
%
s"
%
str
(
new_user_click_tag_list
))
logging
.
warning
(
"tag_id_list:
%
s"
%
str
(
tag_id_list
))
else
:
else
:
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
tag_id_list
,
have_read_topic_id_list
)
...
...
@@ -251,9 +248,7 @@ class CollectData(object):
else
:
tagid_list
=
list
()
logging
.
warning
(
"unknown type msg:
%
s"
%
raw_val_dict
.
get
(
"type"
,
"missing type"
))
logging
.
info
(
"consume click topic_id:
%
s,device_id:
%
s"
%
(
str
(
tagid_list
),
str
(
device_id
)))
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
...
...
search/utils/topic.py
View file @
f4fea10d
...
...
@@ -177,32 +177,28 @@ class TopicUtils(object):
},
{
"filter"
:
{
"term"
:
{
"content_level"
:
6
}
},
"weight"
:
1000
},
{
"filter"
:
{
"term"
:
{
"is_excellent"
:
1
"constant_score"
:{
"filter"
:{
"term"
:
{
"content_level"
:
6
}
}
}
},
"weight"
:
5
00
"weight"
:
6
00
}
]
if
len
(
user_similar_score_list
)
>
0
:
for
item
in
user_similar_score_list
[:
100
]:
score_item
=
2
+
item
[
1
]
functions_list
.
append
(
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"term"
:
{
"user_id"
:
item
[
0
]}}}},
"weight"
:
score_item
,
}
)
#
if len(user_similar_score_list) > 0:
#
for item in user_similar_score_list[:100]:
#
score_item = 2 + item[1]
#
functions_list.append(
#
{
#
"filter": {"bool": {
#
"should": {"term": {"user_id": item[0]}}}},
#
"weight": score_item,
#
}
#
)
if
len
(
attention_user_id_list
)
>
0
:
functions_list
.
append
(
...
...
search/views/tag.py
View file @
f4fea10d
...
...
@@ -155,7 +155,7 @@ def choice_push_tag(device_id, user_id):
@bind
(
"physical/search/identity_tag_name"
)
def
identity_tag_name
(
topic_content
):
try
:
ret_tag_
list
=
lis
t
()
ret_tag_
set
=
se
t
()
redis_key_name
=
"physical:tag_name_set"
body
=
{
...
...
@@ -171,9 +171,9 @@ def identity_tag_name(topic_content):
token_word
=
item
[
"token"
]
is_member
=
redis_client
.
sismember
(
redis_key_name
,
token_word
)
if
is_member
:
ret_tag_
list
.
appen
d
(
token_word
)
ret_tag_
set
.
ad
d
(
token_word
)
return
{
"tag_name_list"
:
ret_tag_list
}
return
{
"tag_name_list"
:
list
(
ret_tag_set
)
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"tag_name_list"
:
[]}
...
...
search/views/topic.py
View file @
f4fea10d
...
...
@@ -73,10 +73,10 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
if
offset
>
0
:
# 首次搜索时不需要过滤已读
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
user_similar_score_redis_key
=
"physical:user_similar_score:user_id:"
+
str
(
user_id
)
redis_user_similar_score_redis_val
=
redis_client
.
get
(
user_similar_score_redis_key
)
user_similar_score_redis_list
=
json
.
loads
(
redis_user_similar_score_redis_val
)
if
redis_user_similar_score_redis_val
else
[]
#
user_similar_score_redis_key = "physical:user_similar_score:user_id:" + str(user_id)
#
redis_user_similar_score_redis_val = redis_client.get(user_similar_score_redis_key)
#
user_similar_score_redis_list = json.loads(
#
redis_user_similar_score_redis_val) if redis_user_similar_score_redis_val else []
attention_tag_list
=
list
()
recommend_topic_list
=
list
()
...
...
@@ -113,8 +113,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
topic_id_list
=
list
()
rank_topic_id_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
,
user_similar_score_list
=
user_similar_score_redis_list
,
index_type
=
"topic-high-star"
,
routing
=
"4,5,6"
,
attention_tag_list
=
attention_tag_list
)
filter_topic_id_list
=
have_read_topic_id_list
,
index_type
=
"topic-high-star"
,
routing
=
"4,5,6"
,
attention_tag_list
=
attention_tag_list
)
if
len
(
recommend_topic_list
)
==
6
and
query
is
None
:
if
(
size
<
11
):
...
...
trans2es/models/topic.py
View file @
f4fea10d
...
...
@@ -209,7 +209,7 @@ class Topic(models.Model):
user_query_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
if
user_query_results
.
count
()
>
0
:
if
user_query_results
[
0
]
.
is_recommend
:
offline_score
+=
2.0
offline_score
+=
2.0
*
10
elif
user_query_results
[
0
]
.
is_shadow
:
user_is_shadow
=
True
...
...
@@ -219,18 +219,18 @@ class Topic(models.Model):
# 帖子等级
if
self
.
content_level
==
'5'
:
offline_score
+=
6.0
offline_score
+=
100.0
*
3
elif
self
.
content_level
==
'4'
:
offline_score
+=
5.0
offline_score
+=
60.0
*
3
elif
self
.
content_level
==
'6'
:
offline_score
+=
400.0
offline_score
+=
200.0
*
3
is_excellent
=
self
.
judge_if_excellent_topic
(
self
.
id
)
if
is_excellent
:
offline_score
+=
200.0
#
is_excellent = self.judge_if_excellent_topic(self.id)
#
if is_excellent:
#
offline_score += 200.0
if
self
.
language_type
==
1
:
offline_score
+=
10
0.0
offline_score
+=
6
0.0
# exposure_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=1).count()
# click_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=2).count()
# uv_num = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=3).count()
...
...
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