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
b2211601
Commit
b2211601
authored
Jul 31, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
add
parents
cb5b5624
508f37f7
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
117 additions
and
69 deletions
+117
-69
Project.xml
.idea/codeStyles/Project.xml
+0
-25
tasks.py
injection/data_sync/tasks.py
+23
-0
es.py
libs/es.py
+3
-1
collect_data.py
linucb/views/collect_data.py
+1
-0
group.py
search/utils/group.py
+2
-1
topic.py
search/utils/topic.py
+1
-0
group.py
search/views/group.py
+41
-3
search_hotword.py
search/views/search_hotword.py
+1
-1
pictorial.json
trans2es/mapping/pictorial.json
+2
-2
topic-high-star.json
trans2es/mapping/topic-high-star.json
+1
-0
topic-star-routing.json
trans2es/mapping/topic-star-routing.json
+8
-8
topic.json
trans2es/mapping/topic.json
+9
-8
pictorial.py
trans2es/models/pictorial.py
+25
-20
No files found.
.idea/codeStyles/Project.xml
View file @
b2211601
...
...
@@ -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
injection/data_sync/tasks.py
View file @
b2211601
...
...
@@ -132,3 +132,26 @@ def get_tag_count():
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
def
del_pictorial_read_ten_redis
():
try
:
now
=
datetime
.
datetime
.
now
()
.
date
()
yes_time
=
now
-
datetime
.
timedelta
(
days
=
10
)
logging
.
info
(
"get yes_time:
%
s"
%
yes_time
)
device_id
=
"123456"
redis_key
=
"physical:home_recommend_pictorial"
+
":device_id:"
+
str
(
device_id
)
logging
.
info
(
"get redis:
%
s"
%
redis_key
)
redis_question_val_list
=
redis_client
.
hgetall
(
redis_key
)
logging
.
info
(
"get redis_question_val_list:
%
s"
%
redis_question_val_list
)
for
item
in
redis_question_val_list
:
items
=
item
.
encode
(
encoding
=
'utf-8'
)
if
items
<
str
(
yes_time
):
redis_client
.
hdel
(
redis_key
,
item
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
libs/es.py
View file @
b2211601
...
...
@@ -414,7 +414,9 @@ class ESPerform(object):
"include"
:
[
"id"
,
"user_id"
]
},
"sort"
:
[
{
"latest_reply_time"
:
{
"order"
:
"desc"
}},
{
"_score"
:
{
"order"
:
"desc"
}},
{
"latest_reply_time"
:{
"order"
:
"desc"
}},
{
"create_time_val"
:
{
"order"
:
"desc"
}},
{
"language_type"
:
{
"order"
:
"asc"
}},
],
...
...
linucb/views/collect_data.py
View file @
b2211601
...
...
@@ -160,6 +160,7 @@ class CollectData(object):
click_topic_tag_list
=
list
()
if
"on_click_feed_topic_card"
==
raw_val_dict
[
"type"
]:
topic_id
=
raw_val_dict
[
"params"
][
"topic_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/group.py
View file @
b2211601
...
...
@@ -93,7 +93,8 @@ class GroupUtils(object):
{
"term"
:
{
"effective"
:
True
}}
],
"must_not"
:
[
{
"term"
:
{
"is_default"
:
1
}}
{
"term"
:
{
"is_default"
:
1
}},
# {"terms": {"id": have_read_pictorial_id_list}}
]
}
},
...
...
search/utils/topic.py
View file @
b2211601
...
...
@@ -1132,6 +1132,7 @@ class TopicUtils(object):
if
sorts
:
q
[
"sort"
]
=
sorts
logging
.
info
(
"get --------qqqq:
%
s"
%
q
)
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
index_name
,
query_body
=
q
,
offset
=
offset
,
size
=
size
...
...
search/views/group.py
View file @
b2211601
...
...
@@ -582,17 +582,20 @@ def pictorial_activity_sort(activity_id=0, offset=0, size=10, sort_type=1):
q
[
"sort"
]
=
process_sort
(
sort_type
)
es_cli_obj
=
ESPerform
.
get_cli
()
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
pictorial_id
=
item
[
"_source"
][
"id"
]
vote_num
=
item
[
"_source"
][
"topic_vote_number"
]
pictorial_ids_list
.
append
({
"pictorial_id"
:
pictorial_id
,
"vote_num"
:
vote_num
})
redis_client
.
set
(
redis_key
,
json
.
dumps
(
pictorial_ids_list
))
else
:
redis_field_val_list
=
redis_client
.
get
(
redis_key
)
pictorial_ids_list_all
=
json
.
loads
(
str
(
redis_field_val_list
,
encoding
=
"utf-8"
))
pictorial_ids_list
=
pictorial_ids_list_all
[
offset
:
size
+
offset
]
return
{
"pictorial_activity_sort"
:
pictorial_ids_list
}
except
:
...
...
@@ -692,13 +695,48 @@ def pictorial_topic_sort_peoplehot(pictorial_id=-1, user_id=-1, offset=0, size=1
@bind
(
"physical/search/pictorial_activity_sort"
)
def
get_pictorial_activeity_sort
(
activity_id
=
0
,
pictorial_id
=
0
):
def
get_pictorial_activeity_sort
(
activity_id
=
-
1
,
pictorial_id
=-
1
):
try
:
pictorial_activity_sort_only
=
[]
"""
判断在不在活动中
"""
q
=
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"activity_join"
:
activity_id
}
},
{
"term"
:
{
"id"
:
pictorial_id
}
},
{
"term"
:
{
"is_cover"
:
True
}
},
{
"term"
:
{
"is_online"
:
True
}
}
]
}
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
"pictorial"
,
q
,
0
,
1
)
if
len
(
result_dict
[
"hits"
])
==
0
:
pictorial_activity_sort_only
.
append
({
"pictorial_id"
:
pictorial_id
,
"pictorial_sort"
:
0
})
return
{
"pictorial_activity_sort"
:
pictorial_activity_sort_only
}
pictorial_ids_list
=
pictorial_activity_sort
(
activity_id
=
activity_id
,
size
=
999
,
offset
=
0
,
sort_type
=
1
)
logging
.
info
(
"get pictorial_ids_list:
%
s"
%
pictorial_ids_list
)
data
=
pictorial_ids_list
.
get
(
"pictorial_activity_sort"
,
[])
logging
.
info
(
"get data:
%
s"
%
data
)
if
data
:
pictorial_ids
=
[]
for
item
in
data
:
...
...
search/views/search_hotword.py
View file @
b2211601
...
...
@@ -41,7 +41,7 @@ def search_hotword(device_id=-1):
for
item
in
results_registr_tag
:
for
word
in
item
.
split
():
tag_val_list
.
add
(
word
)
tag_id_list
=
random
.
sample
(
range
(
0
,
len
(
tag_val_list
)),
6
)
tag_id_list
=
random
.
sample
(
range
(
0
,
len
(
tag_val_list
)),
1
)
for
tag_id
in
tag_id_list
:
tag_val
=
list
(
tag_val_list
)[
tag_id
]
all_tag_name_list
.
add
(
tag_val
)
...
...
trans2es/mapping/pictorial.json
View file @
b2211601
...
...
@@ -21,9 +21,9 @@
"is_default"
:{
"type"
:
"long"
},
"is_cover"
:{
"type"
:
"boolean"
},
"edit_tag_list"
:{
"type"
:
"long"
},
"reply_score"
:{
"type"
:
"long"
},
"topic_vote_number"
:{
"type"
:
"long"
},
"activity_join"
:{
"type"
:
"long"
}
"reply_score"
:{
"type"
:
"long"
}
}
}
trans2es/mapping/topic-high-star.json
View file @
b2211601
...
...
@@ -19,6 +19,7 @@
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"latest_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"latest_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"share_num"
:{
"type"
:
"long"
},
...
...
trans2es/mapping/topic-star-routing.json
View file @
b2211601
...
...
@@ -8,19 +8,19 @@
"vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
//帖子用户名
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"latest_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
...
...
@@ -45,14 +45,14 @@
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"
double
"
},
//
人工降分
"drop_score"
:{
"type"
:
"
long
"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index
"
,
"search_analyzer"
:
"
gm_default_index
"
"analyzer"
:
"
keyword
"
,
"search_analyzer"
:
"
keyword
"
},
"is_excellent"
:{
"type"
:
"long"
},
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
...
...
trans2es/mapping/topic.json
View file @
b2211601
...
...
@@ -8,19 +8,20 @@
"vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
//帖子用户名
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"latest_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"latest_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
...
...
@@ -45,14 +46,14 @@
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"
double
"
},
//
人工降分
"drop_score"
:{
"type"
:
"
long
"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index
"
,
"search_analyzer"
:
"
gm_default_index
"
"analyzer"
:
"
keyword
"
,
"search_analyzer"
:
"
keyword
"
},
"is_excellent"
:{
"type"
:
"long"
},
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
...
...
trans2es/models/pictorial.py
View file @
b2211601
...
...
@@ -8,6 +8,9 @@ from .topic import Topic, Reply
from
.user
import
UserExtra
from
.topic
import
Topic
,
TopicBillBoard
from
.topic
import
Topic
,
Reply
from
.user
import
UserExtra
class
PictorialFollow
(
models
.
Model
):
"""画报关注"""
...
...
@@ -212,30 +215,32 @@ class Pictorial(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
def
get_topic_vote_number
(
self
):
try
:
topic_vote
=
TopicBillBoard
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values
(
"real_vote_cnt"
,
"virt_vote_cnt"
)
total_vote_cnt
=
0
if
topic_vote
:
for
item
in
topic_vote
:
total_vote_cnt
+=
int
(
item
[
"virt_vote_cnt"
])
+
int
(
item
[
"real_vote_cnt"
])
return
total_vote_cnt
def
get_topic_vote_number
(
self
):
try
:
topic_vote
=
TopicBillBoard
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values
(
"real_vote_cnt"
,
"virt_vote_cnt"
)
total_vote_cnt
=
0
if
topic_vote
:
for
item
in
topic_vote
:
total_vote_cnt
+=
int
(
item
[
"virt_vote_cnt"
])
+
int
(
item
[
"real_vote_cnt"
])
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
return
total_vote_cnt
def
get_activity_join
(
self
):
try
:
activicy_list
=
list
(
CommunityPictorialActivityRelation
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"pictorial_activity_id"
,
flat
=
True
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
return
activicy_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_activity_join
(
self
):
try
:
activicy_list
=
list
(
CommunityPictorialActivityRelation
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"pictorial_activity_id"
,
flat
=
True
))
return
activicy_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
class
PictorialTag
(
models
.
Model
):
...
...
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