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
7d8a861b
Commit
7d8a861b
authored
Dec 19, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
14958d22
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
5 deletions
+39
-5
tag.py
search/views/tag.py
+15
-4
tag.json
trans2es/mapping/tag.json
+5
-1
tag.py
trans2es/models/tag.py
+1
-0
tag_transfer.py
trans2es/utils/tag_transfer.py
+18
-0
No files found.
search/views/tag.py
View file @
7d8a861b
...
...
@@ -25,12 +25,23 @@ def query_tag(query,offset,size):
try
:
q
=
{
"query"
:{
"match"
:{
"name"
:
query
"bool"
:{
"must"
:{
"is_online"
:
True
,
"is_deleted"
:
False
},
"should"
:[
{
"match"
:{
"name"
:
query
}}
],
"minimum_should_match"
:
1
}
},
"_source"
:{
"include"
:[
"id"
,
"name"
]
"sort"
:[
{
"near_new_topic_num"
:{
"order"
:
"desc"
}},
{
'_score'
:
{
"order"
:
"desc"
}}
],
"_source"
:
{
"include"
:
[
"id"
,
"name"
]
}
}
q
[
"highlight"
]
=
get_highlight
([
"name"
])
...
...
trans2es/mapping/tag.json
View file @
7d8a861b
...
...
@@ -3,6 +3,9 @@
"properties"
:
{
"id"
:{
"type"
:
"long"
},
"suggest"
:{
"type"
:
"completion"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"standard"
}
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"standard"
},
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"near_new_topic_num"
:{
"type"
:
"long"
}
}
}
\ No newline at end of file
trans2es/models/tag.py
View file @
7d8a861b
...
...
@@ -42,6 +42,7 @@ class Tag(models.Model):
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u"是否删除"
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否上线"
)
name
=
models
.
CharField
(
verbose_name
=
u"标签名称"
,
max_length
=
128
)
description
=
models
.
TextField
(
verbose_name
=
u"标签描述"
)
icon_url
=
models
.
CharField
(
verbose_name
=
u"icon_url"
,
max_length
=
120
)
...
...
trans2es/utils/tag_transfer.py
View file @
7d8a861b
...
...
@@ -5,6 +5,9 @@ import sys
import
logging
import
traceback
from
libs.tools
import
tzlc
from
trans2es.models.topic
import
Topic
from
trans2es.models.tag
import
TopicTag
import
datetime
class
TagTransfer
(
object
):
...
...
@@ -16,6 +19,21 @@ class TagTransfer(object):
res
[
"id"
]
=
instance
.
id
res
[
"suggest"
]
=
instance
.
name
res
[
"name"
]
=
instance
.
name
res
[
"is_online"
]
=
instance
.
is_online
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"near_new_topic_num"
]
=
0
if
instance
.
is_online
==
True
and
instance
.
is_deleted
==
False
:
topic_id_list
=
list
()
sql_result_list
=
TopicTag
.
objects
.
filter
(
tag_id
=
instance
.
id
,
is_online
=
True
)
.
values_list
(
"topic_id"
,
flat
=
True
)
for
item_id
in
sql_result_list
:
topic_id_list
.
append
(
item_id
)
time_base_val
=
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
()
+
datetime
.
timedelta
(
-
7
),
"
%
Y-
%
m-
%
d"
)
topic_num
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
,
is_online
=
True
,
is_deleted
=
False
,
create_time__gte
=
time_base_val
)
.
count
()
res
[
"near_new_topic_num"
]
=
topic_num
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