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
0d63506b
Commit
0d63506b
authored
Apr 10, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!229
parents
6bee61e3
cdde760f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
85 deletions
+32
-85
group.py
search/utils/group.py
+15
-84
pictorial.json
trans2es/mapping/pictorial.json
+3
-1
pictorial.py
trans2es/models/pictorial.py
+13
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+1
-0
No files found.
search/utils/group.py
View file @
0d63506b
...
...
@@ -47,69 +47,35 @@ class GroupUtils(object):
return
{
"total_count"
:
0
,
"hits"
:
[]}
@classmethod
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
):
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
):
try
:
if
not
es_cli_obj
:
es_cli_obj
=
ESPerform
.
get_cli
()
q
=
dict
()
q
[
"query"
]
=
{
"bool"
:
{
"must"
:
[
"bool"
:{
"must"
:[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}}
{
"term"
:{
"is_deleted"
:
False
}},
{
"term"
:
{
"effective"
:
True
}}
]
}
}
q
[
"sort"
]
=
[
{
"high_quality_topic_num"
:
{
"order"
:
"desc"
}}
{
"high_quality_topic_num"
:
{
"order"
:
"desc"
}}
]
q
[
"_source"
]
=
{
"includes"
:
[
"id"
]
"includes"
:[
"id"
]
}
MAX_LOAD
=
1000
sizes
=
max
(
size
,
MAX_LOAD
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
=
0
,
size
=
sizes
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
pictorial_ids_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
pictorial_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
pictorial_del_ids_list
=
[]
if
len
(
pictorial_ids_list
)
>
0
:
for
id
in
pictorial_ids_list
:
q
=
{
"query"
:
{
"bool"
:
{
"must"
:
[{
"term"
:
{
"pictorial_id"
:
id
}
},
{
"terms"
:
{
"content_level"
:
[
3
,
4
,
5
,
0
]
}
},
{
"term"
:
{
"is_online"
:
True
}
}]
}
}
}
topic_ids_list
=
[]
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
offset
=
0
,
size
=
sizes
)
if
len
(
result_dict
[
"hits"
])
>
0
:
topic_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
if
len
(
topic_ids_list
)
>
5
:
pictorial_del_ids_list
.
append
(
id
)
return
pictorial_del_ids_list
[
offset
:(
offset
+
size
)]
else
:
return
[]
return
pictorial_ids_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
...
...
@@ -130,54 +96,18 @@ class GroupUtils(object):
"must"
:
[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"user_id"
:
user_id
}},
{
"term"
:
{
"is_deleted"
:
False
}}
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:{
"effective"
:
True
}}
]
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"attention_pictorial_id_list"
]
}
MAX_LOAD
=
1000
sizes
=
max
(
size
,
MAX_LOAD
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"user"
,
q
,
offset
=
0
,
size
=
sizes
)
pictorial_ids_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
pictorial_ids_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"attention_pictorial_id_list"
]
pictorial_del_ids_list
=
[]
if
len
(
pictorial_ids_list
)
>
0
:
for
id
in
pictorial_ids_list
:
q
=
{
"query"
:
{
"bool"
:
{
"must"
:
[{
"term"
:
{
"pictorial_id"
:
id
}
},
{
"terms"
:
{
"content_level"
:
[
3
,
4
,
5
,
0
]
}
},
{
"term"
:
{
"is_online"
:
True
}
}]
}
}
}
topic_ids_list
=
[]
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
offset
=
0
,
size
=
sizes
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"user"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
topic_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
if
len
(
topic_ids_list
)
>
5
:
pictorial_del_ids_list
.
append
(
id
)
return
pictorial_del_ids_list
[
offset
:(
offset
+
size
)]
return
result_dict
[
"hits"
][
0
][
"_source"
][
"attention_pictorial_id_list"
]
else
:
return
[]
...
...
@@ -185,6 +115,7 @@ class GroupUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_pictorial_ids_by_aggs
(
cls
,
pictorial_ids_list
,
es_cli_obj
=
None
):
"""
...
...
trans2es/mapping/pictorial.json
View file @
0d63506b
...
...
@@ -15,6 +15,7 @@
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"tag_id"
:{
"type"
:
"long"
},
"tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"topic_id_list"
:{
"type"
:
"long"
}
"topic_id_list"
:{
"type"
:
"long"
},
"effective"
:{
"type"
:
"boolean"
}
}
}
\ No newline at end of file
trans2es/models/pictorial.py
View file @
0d63506b
...
...
@@ -72,6 +72,19 @@ class Pictorial(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_effective
(
self
,
topic_id_list
):
try
:
topic_id_list
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
,
content_level__in
=
[
3
,
4
,
5
,
0
],
is_online
=
True
)
.
count
()
if
topic_id_list
>=
5
:
return
True
else
:
return
False
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
# 获取前一天4,5星发帖数
def
get_high_quality_topic_num
(
self
):
try
:
...
...
trans2es/utils/pictorial_transfer.py
View file @
0d63506b
...
...
@@ -37,6 +37,7 @@ class PictorialTransfer(object):
res
[
"tag_id"
]
=
tag_id
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
(
tag_id
)
res
[
"topic_id_list"
]
=
instance
.
get_topic_id
()
res
[
"effective"
]
=
instance
.
get_effective
(
res
[
"topic_id_list"
])
return
res
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