Show More
@@ -36,6 +36,7 b' from tg.i18n import ugettext as _' | |||||
36 | from webob.exc import HTTPFound |
|
36 | from webob.exc import HTTPFound | |
37 |
|
37 | |||
38 | import kallithea |
|
38 | import kallithea | |
|
39 | import kallithea.lib.indexers.daemon | |||
39 | from kallithea.controllers import base |
|
40 | from kallithea.controllers import base | |
40 | from kallithea.lib import webutils |
|
41 | from kallithea.lib import webutils | |
41 | from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired |
|
42 | from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired | |
@@ -378,7 +379,7 b' class SettingsController(base.BaseContro' | |||||
378 | if request.POST: |
|
379 | if request.POST: | |
379 | repo_location = self._get_hg_ui_settings()['paths_root_path'] |
|
380 | repo_location = self._get_hg_ui_settings()['paths_root_path'] | |
380 | full_index = request.POST.get('full_index', False) |
|
381 | full_index = request.POST.get('full_index', False) | |
381 |
|
|
382 | kallithea.lib.indexers.daemon.whoosh_index(repo_location, full_index) | |
382 | webutils.flash(_('Whoosh reindex task scheduled'), category='success') |
|
383 | webutils.flash(_('Whoosh reindex task scheduled'), category='success') | |
383 | raise HTTPFound(location=url('admin_settings_search')) |
|
384 | raise HTTPFound(location=url('admin_settings_search')) | |
384 |
|
385 |
@@ -18,7 +18,10 b' import logging' | |||||
18 |
|
18 | |||
19 |
|
19 | |||
20 | class CeleryConfig(object): |
|
20 | class CeleryConfig(object): | |
21 | imports = ['kallithea.model.async_tasks'] |
|
21 | imports = [ | |
|
22 | 'kallithea.lib.indexers.daemon', | |||
|
23 | 'kallithea.model.async_tasks', | |||
|
24 | ] | |||
22 | task_always_eager = False |
|
25 | task_always_eager = False | |
23 |
|
26 | |||
24 | list_config_names = {'imports', 'accept_content'} |
|
27 | list_config_names = {'imports', 'accept_content'} |
@@ -32,9 +32,11 b' import traceback' | |||||
32 | from shutil import rmtree |
|
32 | from shutil import rmtree | |
33 | from time import mktime |
|
33 | from time import mktime | |
34 |
|
34 | |||
|
35 | from tg import config | |||
35 | from whoosh.index import create_in, exists_in, open_dir |
|
36 | from whoosh.index import create_in, exists_in, open_dir | |
36 | from whoosh.qparser import QueryParser |
|
37 | from whoosh.qparser import QueryParser | |
37 |
|
38 | |||
|
39 | from kallithea.lib import celerylib | |||
38 | from kallithea.lib.conf import INDEX_EXTENSIONS, INDEX_FILENAMES |
|
40 | from kallithea.lib.conf import INDEX_EXTENSIONS, INDEX_FILENAMES | |
39 | from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA |
|
41 | from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA | |
40 | from kallithea.lib.utils2 import safe_str |
|
42 | from kallithea.lib.utils2 import safe_str | |
@@ -444,3 +446,12 b' class WhooshIndexingDaemon(object):' | |||||
444 | self.build_indexes() |
|
446 | self.build_indexes() | |
445 | else: |
|
447 | else: | |
446 | self.update_indexes() |
|
448 | self.update_indexes() | |
|
449 | ||||
|
450 | ||||
|
451 | @celerylib.task | |||
|
452 | @celerylib.locked_task | |||
|
453 | def whoosh_index(repo_location, full_index): | |||
|
454 | index_location = config['index_dir'] | |||
|
455 | WhooshIndexingDaemon(index_location=index_location, | |||
|
456 | repo_location=repo_location) \ | |||
|
457 | .run(full_index=full_index) |
@@ -41,27 +41,17 b' from tg import config' | |||||
41 |
|
41 | |||
42 | import kallithea |
|
42 | import kallithea | |
43 | from kallithea.lib import celerylib, conf, ext_json, hooks |
|
43 | from kallithea.lib import celerylib, conf, ext_json, hooks | |
44 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon |
|
|||
45 | from kallithea.lib.utils2 import asbool, ascii_bytes |
|
44 | from kallithea.lib.utils2 import asbool, ascii_bytes | |
46 | from kallithea.lib.vcs.utils import author_email, author_name |
|
45 | from kallithea.lib.vcs.utils import author_email, author_name | |
47 | from kallithea.model import db, meta, repo, userlog |
|
46 | from kallithea.model import db, meta, repo, userlog | |
48 |
|
47 | |||
49 |
|
48 | |||
50 |
__all__ = [ |
|
49 | __all__ = ['get_commits_stats', 'send_email'] | |
51 |
|
50 | |||
52 |
|
51 | |||
53 | log = celery.utils.log.get_task_logger(__name__) |
|
52 | log = celery.utils.log.get_task_logger(__name__) | |
54 |
|
53 | |||
55 |
|
54 | |||
56 | @celerylib.task |
|
|||
57 | @celerylib.locked_task |
|
|||
58 | def whoosh_index(repo_location, full_index): |
|
|||
59 | index_location = config['index_dir'] |
|
|||
60 | WhooshIndexingDaemon(index_location=index_location, |
|
|||
61 | repo_location=repo_location) \ |
|
|||
62 | .run(full_index=full_index) |
|
|||
63 |
|
||||
64 |
|
||||
65 | def _author_username(author): |
|
55 | def _author_username(author): | |
66 | """Return the username of the user identified by the email part of the 'author' string, |
|
56 | """Return the username of the user identified by the email part of the 'author' string, | |
67 | default to the name or email. |
|
57 | default to the name or email. |
@@ -159,7 +159,6 b' known_violations = set([' | |||||
159 | ('kallithea.lib.utils', 'kallithea.model.db'), |
|
159 | ('kallithea.lib.utils', 'kallithea.model.db'), | |
160 | ('kallithea.lib.utils', 'kallithea.model.scm'), |
|
160 | ('kallithea.lib.utils', 'kallithea.model.scm'), | |
161 | ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), |
|
161 | ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), | |
162 | ('kallithea.model.async_tasks', 'kallithea.lib.indexers'), |
|
|||
163 | ('kallithea.model.async_tasks', 'kallithea.model'), |
|
162 | ('kallithea.model.async_tasks', 'kallithea.model'), | |
164 | ('kallithea.model', 'kallithea.lib.auth'), # auth.HasXXX |
|
163 | ('kallithea.model', 'kallithea.lib.auth'), # auth.HasXXX | |
165 | ('kallithea.model', 'kallithea.lib.auth_modules'), # validators |
|
164 | ('kallithea.model', 'kallithea.lib.auth_modules'), # validators |
General Comments 0
You need to be logged in to leave comments.
Login now