Commit 28fbad38 authored by Michal Čihař's avatar Michal Čihař

Move flushing code to search module

parent ab18292c
......@@ -67,6 +67,15 @@ def create_index(sender=None, **kwargs):
create_source_index()
def flush_index():
'''
Flushes any possibly buffered writes to index.
'''
FULLTEXT_INDEX._source_writer.commit()
for lang in FULLTEXT_INDEX._target_writer:
FULLTEXT_INDEX._target_writer[lang].commit()
def update_index(units, source_units = None):
'''
Updates fulltext index for given set of units.
......
......@@ -24,7 +24,7 @@ Tests for management commands.
from trans.tests.models import RepoTestCase
from django.core.management import call_command
from trans.search import FULLTEXT_INDEX
from trans.search import flush_index
class ImportProjectTest(RepoTestCase):
......@@ -117,10 +117,8 @@ class PeriodicTest(RepoTestCase):
def test_update_index(self):
# Flush possible caches
FULLTEXT_INDEX._source_writer.commit()
for lang in FULLTEXT_INDEX._target_writer:
FULLTEXT_INDEX._target_writer[lang].commit()
flush_index()
# Test the command
call_command(
'update_index'
)
......@@ -200,9 +198,7 @@ class RebuildIndexTest(CheckGitTest):
def setUp(self):
super(RebuildIndexTest, self).setUp()
# Flush possible caches
FULLTEXT_INDEX._source_writer.commit()
for lang in FULLTEXT_INDEX._target_writer:
FULLTEXT_INDEX._target_writer[lang].commit()
flush_index()
def test_all_clean(self):
self.do_test(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment