diff --git a/readthedocs/search/tasks.py b/readthedocs/search/tasks.py index c5432110c7e..cd82f8fe25e 100644 --- a/readthedocs/search/tasks.py +++ b/readthedocs/search/tasks.py @@ -171,16 +171,6 @@ def record_search_query(project_slug, version_slug, query, total_results, time_s partial_query.save() return - # don't record query with zero results. - if not total_results: - log.debug( - 'Not recording search query because of zero results. Passed arguments: ' - 'project_slug: %s, version_slug: %s, query: %s, total_results: %s, time: %s' % ( - project_slug, version_slug, query, total_results, time - ) - ) - return - project = Project.objects.filter(slug=project_slug).first() if not project: log.debug( diff --git a/readthedocs/search/tests/test_search_tasks.py b/readthedocs/search/tests/test_search_tasks.py index 92501dfd367..8cc9c9cb757 100644 --- a/readthedocs/search/tests/test_search_tasks.py +++ b/readthedocs/search/tests/test_search_tasks.py @@ -87,8 +87,8 @@ def test_partial_queries_are_not_recorded(self, api_client): SearchQuery.objects.all().first().query == 'stack overflow' ), 'one SearchQuery should be there because partial queries gets updated' - def test_search_query_not_recorded_when_results_are_zero(self, api_client): - """Test that search queries are not recorded when they have zero results.""" + def test_search_query_recorded_when_results_are_zero(self, api_client): + """Test that search queries are recorded when they have zero results.""" assert ( SearchQuery.objects.all().count() == 0 @@ -102,10 +102,8 @@ def test_search_query_not_recorded_when_results_are_zero(self, api_client): } resp = api_client.get(self.url, search_params) - assert (resp.data['count'] == 0) - assert ( - SearchQuery.objects.all().count() == 0 - ), 'there should be 0 obj since there were no results.' + assert resp.data['count'] == 0 + assert SearchQuery.objects.all().count() == 1 def test_delete_old_search_queries_from_db(self, project): """Test that the old search queries are being deleted."""