diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 2b699c9e971..5d9940ff68f 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -940,12 +940,6 @@ def search_analytics_view(request, project_slug): query_count_of_1_month = SearchQuery.generate_queries_count_of_one_month( project_slug ) - # data for plotting the doughnut-chart - distribution_of_top_queries = SearchQuery.generate_distribution_of_top_queries( - project_slug, - 10, - ) - now = timezone.now() queries = [] qs = SearchQuery.objects.filter(project=project) @@ -968,7 +962,6 @@ def search_analytics_view(request, project_slug): 'queries': queries, 'show_analytics': True, 'query_count_of_1_month': query_count_of_1_month, - 'distribution_of_top_queries': distribution_of_top_queries, } ) diff --git a/readthedocs/rtd_tests/tests/test_views.py b/readthedocs/rtd_tests/tests/test_views.py index 027a34880c5..66ae8f97ca9 100644 --- a/readthedocs/rtd_tests/tests/test_views.py +++ b/readthedocs/rtd_tests/tests/test_views.py @@ -304,23 +304,6 @@ def test_top_queries(self): list(resp.context['queries']), ) - def test_distribution_of_top_queries(self): - with mock.patch('django.utils.timezone.now') as test_time: - test_time.return_value = self.test_time - - expected_result = { - 'labels': ['hello world', 'documentation', 'read the docs', 'advertising', - 'elasticsearch', 'sphinx', 'github', 'hello', 'search'], - 'int_data': [5, 4, 4, 3, 2, 2, 1, 1, 1], - } - resp = self.client.get(self.analyics_page, {'version': self.version.slug}) - - self.assertEqual(resp.status_code, 200) - self.assertDictEqual( - expected_result, - resp.context['distribution_of_top_queries'], - ) - def test_query_count_of_1_month(self): with mock.patch('django.utils.timezone.now') as test_time: test_time.return_value = self.test_time diff --git a/readthedocs/search/models.py b/readthedocs/search/models.py index 45f13640294..53fedecaf96 100644 --- a/readthedocs/search/models.py +++ b/readthedocs/search/models.py @@ -92,48 +92,3 @@ def generate_queries_count_of_one_month(cls, project_slug): } return final_data - - @classmethod - def generate_distribution_of_top_queries(cls, project_slug, n): - """ - Returns top `n` most searched queries with their count. - - Structure of returned data is compatible to make graphs. - Sample returned data:: - { - 'labels': ['read the docs', 'documentation', 'sphinx'], - 'int_data': [150, 200, 143] - } - This data shows that `read the docs` was searched 150 times, - `documentation` was searched 200 times and `sphinx` was searched 143 times. - """ - qs = cls.objects.filter(project__slug=project_slug) - - # total searches ever made - total_count = len(qs) - - # search queries with their count - # Eg. [('read the docs', 150), ('documentation', 200), ('sphinx', 143')] - count_of_each_query = ( - qs.values('query') - .annotate(count=Count('id')) - .order_by('-count') - .values_list('query', 'count') - ) - - # total number of searches made for top `n` queries - count_of_top_n = sum([value[1] for value in count_of_each_query][:n]) - - # total number of remaining searches - count_of_other = total_count - count_of_top_n - - final_data = { - 'labels': [value[0] for value in count_of_each_query][:n], - 'int_data': [value[1] for value in count_of_each_query][:n], - } - - if count_of_other: - final_data['labels'].append('Other queries') - final_data['int_data'].append(count_of_other) - - return final_data diff --git a/readthedocs/templates/projects/projects_search_analytics.html b/readthedocs/templates/projects/projects_search_analytics.html index b84129c6275..e162fd21e03 100644 --- a/readthedocs/templates/projects/projects_search_analytics.html +++ b/readthedocs/templates/projects/projects_search_analytics.html @@ -35,13 +35,6 @@