changeset 7452:d5ab6db3b9e2

search: better messaging when the index hasn't been built yet Improve the situation around the "Please run whoosh indexer" message. 1. It is not a situation that justifies logging a stack trace. 2. Don't just say "whoosh indexer" - it actually has a name: kallithea-cli index-create . 3. Don't report server side commands in the user interface.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 23 Dec 2018 21:16:07 +0100
parents 8b6e87245e57
children b5419cd0ac40
files kallithea/controllers/search.py kallithea/tests/functional/test_search.py
diffstat 2 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/search.py	Sun Dec 23 21:16:07 2018 +0100
+++ b/kallithea/controllers/search.py	Sun Dec 23 21:16:07 2018 +0100
@@ -136,10 +136,8 @@
                     c.runtime = _('Invalid search query. Try quoting it.')
                 searcher.close()
             except EmptyIndexError:
-                log.error(traceback.format_exc())
-                log.error('Empty Index data')
-                c.runtime = _('There is no index to search in. '
-                              'Please run whoosh indexer')
+                log.error("Empty search index - run 'kallithea-cli index-create' regularly")
+                c.runtime = _('The server has no search index.')
             except Exception:
                 log.error(traceback.format_exc())
                 c.runtime = _('An error occurred during search operation.')
--- a/kallithea/tests/functional/test_search.py	Sun Dec 23 21:16:07 2018 +0100
+++ b/kallithea/tests/functional/test_search.py	Sun Dec 23 21:16:07 2018 +0100
@@ -24,8 +24,7 @@
         with mock.patch('kallithea.controllers.search.config', config_mock):
             response = self.app.get(url(controller='search', action='index'),
                                     {'q': HG_REPO})
-            response.mustcontain('There is no index to search in. '
-                                 'Please run whoosh indexer')
+            response.mustcontain('The server has no search index.')
 
     def test_normal_search(self):
         self.log_user()