Changeset - d5ab6db3b9e2
[Not reviewed]
default
0 2 0
Mads Kiilerich - 7 years ago 2018-12-23 21:16:07
mads@kiilerich.com
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.
2 files changed with 3 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/search.py
Show inline comments
 
@@ -133,16 +133,14 @@ class SearchController(BaseRepoControlle
 
                    )
 

	
 
                except QueryParserError:
 
                    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.')
 

	
 
        # Return a rendered template
 
        return render('/search/search.html')
kallithea/tests/functional/test_search.py
Show inline comments
 
@@ -21,14 +21,13 @@ class TestSearchController(TestControlle
 
                'index_dir': str(tmpdir),
 
            }
 
        }
 
        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()
 
        response = self.app.get(url(controller='search', action='index'),
 
                                {'q': 'def repo'})
 
        response.mustcontain('58 results')
0 comments (0 inline, 0 general)