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
34b61f2b
Commit
34b61f2b
authored
Jun 07, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for offloading indexing (issue #47)
parent
60765fc6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
0 deletions
+59
-0
docs/config.rst
docs/config.rst
+11
-0
weblate/settings.py
weblate/settings.py
+3
-0
weblate/trans/management/commands/update_index.py
weblate/trans/management/commands/update_index.py
+37
-0
weblate/trans/managers.py
weblate/trans/managers.py
+5
-0
weblate/trans/models.py
weblate/trans/models.py
+3
-0
No files found.
docs/config.rst
View file @
34b61f2b
...
...
@@ -55,6 +55,17 @@ All settings are stored in :file:`settings.py` (as usual for Django).
How many messages around current one to show during translating.
.. envvar:: OFFLOAD_INDEXING
Offload updating of fulltext index to separate process. This heavily
improves responsiveness of online operation on expense of slightly
outdated index, which might still point to older content.
While enabling this, don't forget scheduling runs of
:program:`./manage.py update_index` in cron or similar tool.
This is recommended setup for production use.
.. envvar:: SIMILAR_MESSAGES
Number of similar messages to lookup. This is not a hard limit, just a
...
...
weblate/settings.py
View file @
34b61f2b
...
...
@@ -275,6 +275,9 @@ SIMILAR_MESSAGES = 5
# Enable lazy commits
LAZY_COMMITS
=
True
# Offload indexing
OFFLOAD_INDEXING
=
False
# Where to put Whoosh index
WHOOSH_INDEX
=
os
.
path
.
join
(
WEB_ROOT
,
'whoosh-index'
)
...
...
weblate/trans/management/commands/update_index.py
0 → 100644
View file @
34b61f2b
from
django.core.management.base
import
BaseCommand
from
weblate.trans.models
import
IndexUpdate
from
weblate.lang.models
import
Language
from
weblate.trans.search
import
FULLTEXT_INDEX
,
create_source_index
,
create_target_index
from
optparse
import
make_option
class
Command
(
BaseCommand
):
help
=
'updates index for fulltext search'
def
handle
(
self
,
*
args
,
**
options
):
languages
=
Language
.
objects
.
all
()
base
=
IndexUpdate
.
objects
.
all
()
if
base
.
count
()
==
0
:
return
with
FULLTEXT_INDEX
.
source_writer
(
buffered
=
False
)
as
writer
:
for
update
in
base
.
iterator
():
Unit
.
objects
.
add_to_source_index
(
update
.
unit
.
checksum
,
update
.
unit
.
source
,
update
.
unit
.
context
,
writer
)
for
lang
in
languages
:
with
FULLTEXT_INDEX
.
target_writer
(
lang
=
lang
.
code
,
buffered
=
False
)
as
writer
:
for
update
in
base
.
filter
(
unit__translation__language
=
lang
).
exclude
(
unit__target
=
''
).
iterator
():
Unit
.
objects
.
add_to_target_index
(
update
.
unit
.
checksum
,
update
.
unit
.
target
,
writer
)
base
.
delete
()
weblate/trans/managers.py
View file @
34b61f2b
...
...
@@ -193,6 +193,11 @@ class UnitManager(models.Manager):
'''
Updates/Adds to all indices given unit.
'''
if
settings
.
OFFLOAD_INDEXING
:
from
weblate.trans.models
import
IndexUpdate
IndexUpdate
.
objects
.
get_or_create
(
unit
=
unit
)
return
writer_target
=
FULLTEXT_INDEX
.
target_writer
(
unit
.
translation
.
language
.
code
)
writer_source
=
FULLTEXT_INDEX
.
source_writer
()
...
...
weblate/trans/models.py
View file @
34b61f2b
...
...
@@ -1425,3 +1425,6 @@ class Change(models.Model):
self
.
timestamp
,
self
.
user
,
)
class
IndexUpdate
(
models
.
Model
):
unit
=
models
.
ForeignKey
(
Unit
)
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