Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
aa228e86
Commit
aa228e86
authored
Jan 17, 2016
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
b33f6771
9933d1bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
21 deletions
+32
-21
weblate/trans/models/unit.py
weblate/trans/models/unit.py
+3
-3
weblate/trans/search.py
weblate/trans/search.py
+29
-18
No files found.
weblate/trans/models/unit.py
View file @
aa228e86
...
...
@@ -670,9 +670,9 @@ class Unit(models.Model, LoggerMixin):
fuzzy
=
True
,
previous_source
=
previous_source
,
)
# Update source index
, it's enough to do it for one as we index by
# checksum which is same for all
update_index_unit
(
self
,
True
)
# Update source index
for
unit
in
same_source
.
interator
():
update_index_unit
(
unit
,
True
)
def
generate_change
(
self
,
request
,
author
,
oldunit
,
change_action
):
"""
...
...
weblate/trans/search.py
View file @
aa228e86
...
...
@@ -230,13 +230,20 @@ def update_index_unit(unit, source=True):
update_target_unit_index
(
writer
,
unit
)
def
base_search
(
searcher
,
field
,
schema
,
query
):
def
base_search
(
index
,
query
,
params
,
search
,
schema
):
'''
Wrapper for fulltext search.
'''
parser
=
qparser
.
QueryParser
(
field
,
schema
)
parsed
=
parser
.
parse
(
query
)
return
[
result
[
'pk'
]
for
result
in
searcher
.
search
(
parsed
)]
with
index
.
searcher
()
as
searcher
:
queries
=
[]
for
param
in
params
:
if
search
[
param
]:
parser
=
qparser
.
QueryParser
(
param
,
schema
)
queries
.
append
(
parser
.
parse
(
query
)
)
terms
=
reduce
(
lambda
x
,
y
:
x
|
y
,
queries
)
return
[
result
[
'pk'
]
for
result
in
searcher
.
search
(
terms
)]
def
fulltext_search
(
query
,
lang
,
params
):
...
...
@@ -255,22 +262,26 @@ def fulltext_search(query, lang, params):
search
.
update
(
params
)
if
search
[
'source'
]
or
search
[
'context'
]
or
search
[
'location'
]:
index
=
get_source_index
()
with
index
.
searcher
()
as
searcher
:
for
param
in
(
'source'
,
'context'
,
'location'
):
if
search
[
param
]:
pks
.
update
(
base_search
(
searcher
,
param
,
SourceSchema
(),
query
)
)
pks
.
update
(
base_search
(
get_source_index
(),
query
,
(
'source'
,
'context'
,
'location'
),
search
,
SourceSchema
()
)
)
if
search
[
'target'
]
or
search
[
'comment'
]:
index
=
get_target_index
(
lang
)
with
index
.
searcher
()
as
searcher
:
for
param
in
(
'target'
,
'comment'
):
if
search
[
param
]:
pks
.
update
(
base_search
(
searcher
,
param
,
TargetSchema
(),
query
)
)
pks
.
update
(
base_search
(
get_target_index
(
lang
),
query
,
(
'target'
,
'comment'
),
search
,
TargetSchema
()
)
)
return
pks
...
...
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