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
e69e62fc
Commit
e69e62fc
authored
Oct 31, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update source index only when needed
parent
83dd5a3b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
11 deletions
+189
-11
weblate/trans/management/commands/update_index.py
weblate/trans/management/commands/update_index.py
+1
-1
weblate/trans/managers.py
weblate/trans/managers.py
+8
-7
weblate/trans/migrations/0015_auto__add_field_indexupdate_source.py
...ans/migrations/0015_auto__add_field_indexupdate_source.py
+170
-0
weblate/trans/models.py
weblate/trans/models.py
+10
-3
No files found.
weblate/trans/management/commands/update_index.py
View file @
e69e62fc
...
...
@@ -36,7 +36,7 @@ class Command(BaseCommand):
return
with
FULLTEXT_INDEX
.
source_writer
(
buffered
=
False
)
as
writer
:
for
update
in
base
.
iterator
():
for
update
in
base
.
filter
(
source
=
True
).
iterator
():
Unit
.
objects
.
add_to_source_index
(
update
.
unit
.
checksum
,
update
.
unit
.
source
,
...
...
weblate/trans/managers.py
View file @
e69e62fc
...
...
@@ -271,23 +271,24 @@ class UnitManager(models.Manager):
target
=
unicode
(
target
),
)
def
add_to_index
(
self
,
unit
):
def
add_to_index
(
self
,
unit
,
source
=
True
):
'''
Updates/Adds to all indices given unit.
'''
if
settings
.
OFFLOAD_INDEXING
:
from
weblate.trans.models
import
IndexUpdate
IndexUpdate
.
objects
.
get_or_create
(
unit
=
unit
)
IndexUpdate
.
objects
.
get_or_create
(
unit
=
unit
,
source
=
source
)
return
writer_target
=
FULLTEXT_INDEX
.
target_writer
(
unit
.
translation
.
language
.
code
)
writer_source
=
FULLTEXT_INDEX
.
source_writer
()
self
.
add_to_source_index
(
unit
.
checksum
,
unit
.
source
,
unit
.
context
,
writer_source
)
if
source
:
self
.
add_to_source_index
(
unit
.
checksum
,
unit
.
source
,
unit
.
context
,
writer_source
)
self
.
add_to_target_index
(
unit
.
checksum
,
unit
.
target
,
...
...
weblate/trans/migrations/0015_auto__add_field_indexupdate_source.py
0 → 100644
View file @
e69e62fc
This diff is collapsed.
Click to expand it.
weblate/trans/models.py
View file @
e69e62fc
...
...
@@ -2159,6 +2159,7 @@ class Unit(models.Model):
# Pop parameter indicating that we don't have to process content
same_content
=
kwargs
.
pop
(
'same_content'
,
False
)
same_fuzzy
=
kwargs
.
pop
(
'same_fuzzy'
,
False
)
force_insert
=
kwargs
.
get
(
'force_insert'
,
False
)
# Actually save the unit
super
(
Unit
,
self
).
save
(
*
args
,
**
kwargs
)
...
...
@@ -2166,9 +2167,14 @@ class Unit(models.Model):
# Update checks if content or fuzzy flag has changed
if
not
same_content
or
not
same_fuzzy
:
self
.
check
()
# Update fulltext index if content has changed
if
not
same_content
:
Unit
.
objects
.
add_to_index
(
self
)
# Update fulltext index if content has changed or this is a new unit
if
force_insert
:
# New unit, need to update both source and target index
Unit
.
objects
.
add_to_index
(
self
,
True
)
else
:
# We only update target index here
Unit
.
objects
.
add_to_index
(
self
,
False
)
def
get_location_links
(
self
):
'''
...
...
@@ -2469,6 +2475,7 @@ class Change(models.Model):
class
IndexUpdate
(
models
.
Model
):
unit
=
models
.
ForeignKey
(
Unit
)
source
=
models
.
BooleanField
(
default
=
True
)
def
get_version_module
(
module
,
name
,
url
):
try
:
...
...
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