From f9367d38fbec52bece210f240c29441a3d118223 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 19 Jan 2021 18:00:17 -0500 Subject: [PATCH 1/4] Remove STORE_PAGEVIEWS feature --- readthedocs/analytics/proxied_api.py | 3 --- readthedocs/analytics/tests.py | 5 ----- readthedocs/projects/views/private.py | 2 +- readthedocs/rtd_tests/tests/test_footer.py | 7 ------- 4 files changed, 1 insertion(+), 16 deletions(-) diff --git a/readthedocs/analytics/proxied_api.py b/readthedocs/analytics/proxied_api.py index 9521ac163cc..c6cd8269f76 100644 --- a/readthedocs/analytics/proxied_api.py +++ b/readthedocs/analytics/proxied_api.py @@ -62,9 +62,6 @@ def get(self, request, *args, **kwargs): # pylint: disable=no-self-use def increase_page_view_count(self, request, project, version, absolute_uri): """Increase the page view count for the given project.""" - if not absolute_uri or not project.has_feature(Feature.STORE_PAGEVIEWS): - return - unresolved = unresolve_from_request(request, absolute_uri) if not unresolved: return diff --git a/readthedocs/analytics/tests.py b/readthedocs/analytics/tests.py index 8360638ad33..c682c268764 100644 --- a/readthedocs/analytics/tests.py +++ b/readthedocs/analytics/tests.py @@ -129,11 +129,6 @@ def test_increase_page_view_count(self): PageView.objects.all().count() == 0 ) - feature, _ = Feature.objects.get_or_create( - feature_id=Feature.STORE_PAGEVIEWS, - ) - self.project.feature_set.add(feature) - # testing for yesterday with mock.patch('readthedocs.analytics.tasks.timezone.now') as mocked_timezone: mocked_timezone.return_value = self.yesterday diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 65309fddb60..bdfc2cd7888 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -1131,7 +1131,7 @@ def get_context_data(self, **kwargs): def _is_enabled(self, project): """Should we show traffic analytics for this project?""" - return project.has_feature(Feature.STORE_PAGEVIEWS) + return True class TrafficAnalyticsView(SettingsOverrideObject): diff --git a/readthedocs/rtd_tests/tests/test_footer.py b/readthedocs/rtd_tests/tests/test_footer.py index 9098283107c..a0053a5af2b 100644 --- a/readthedocs/rtd_tests/tests/test_footer.py +++ b/readthedocs/rtd_tests/tests/test_footer.py @@ -452,13 +452,6 @@ def setUp(self): ) self.host = 'pip.readthedocs.io' - # Run tests with all available features - # that can increase the number of queries. - feature, _ = Feature.objects.get_or_create( - feature_id=Feature.STORE_PAGEVIEWS, - ) - self.pip.feature_set.add(feature) - def test_version_queries(self): with self.assertNumQueries(self.EXPECTED_QUERIES): response = self.client.get(self.url, HTTP_HOST=self.host) From 81558b7a9572f09e0240477b4736536808dbd1b5 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 19 Jan 2021 18:00:46 -0500 Subject: [PATCH 2/4] Remove FORCE_SPHINX_FROM_VENV --- readthedocs/doc_builder/backends/sphinx.py | 11 +++-------- readthedocs/projects/models.py | 10 ---------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/readthedocs/doc_builder/backends/sphinx.py b/readthedocs/doc_builder/backends/sphinx.py index 051e776357f..c9bedc2fb36 100644 --- a/readthedocs/doc_builder/backends/sphinx.py +++ b/readthedocs/doc_builder/backends/sphinx.py @@ -282,15 +282,10 @@ def build(self): return cmd_ret.successful def get_sphinx_cmd(self): - if self.project.has_feature(Feature.FORCE_SPHINX_FROM_VENV): - return ( - self.python_env.venv_bin(filename='python'), - '-m', - 'sphinx', - ) return ( - 'python', - self.python_env.venv_bin(filename='sphinx-build'), + self.python_env.venv_bin(filename='python'), + '-m', + 'sphinx', ) def sphinx_parallel_arg(self): diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index cb4cb432dec..f28a9ac4ec8 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1596,10 +1596,8 @@ def add_features(sender, **kwargs): INDEX_FROM_HTML_FILES = 'index_from_html_files' SEARCH_SUBPROJECTS_ON_DEFAULT_VERSION = 'search_subprojects_on_default_version' - FORCE_SPHINX_FROM_VENV = 'force_sphinx_from_venv' LIST_PACKAGES_INSTALLED_ENV = 'list_packages_installed_env' VCS_REMOTE_LISTING = 'vcs_remote_listing' - STORE_PAGEVIEWS = 'store_pageviews' SPHINX_PARALLEL = 'sphinx_parallel' USE_SPHINX_BUILDERS = 'use_sphinx_builders' DEDUPLICATE_BUILDS = 'deduplicate_builds' @@ -1726,10 +1724,6 @@ def add_features(sender, **kwargs): ), ), - ( - FORCE_SPHINX_FROM_VENV, - _('Force to use Sphinx from the current virtual environment'), - ), ( LIST_PACKAGES_INSTALLED_ENV, _( @@ -1741,10 +1735,6 @@ def add_features(sender, **kwargs): VCS_REMOTE_LISTING, _('Use remote listing in VCS (e.g. git ls-remote) if supported for sync versions'), ), - ( - STORE_PAGEVIEWS, - _('Store pageviews for this project'), - ), ( SPHINX_PARALLEL, _('Use "-j auto" when calling sphinx-build'), From 092f8d9b79e7855387e3095c4625a1202e3d59ae Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 19 Jan 2021 18:05:58 -0500 Subject: [PATCH 3/4] Unused import --- readthedocs/analytics/proxied_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/analytics/proxied_api.py b/readthedocs/analytics/proxied_api.py index c6cd8269f76..30a0d263c87 100644 --- a/readthedocs/analytics/proxied_api.py +++ b/readthedocs/analytics/proxied_api.py @@ -12,7 +12,7 @@ from readthedocs.api.v2.permissions import IsAuthorizedToViewVersion from readthedocs.core.unresolver import unresolve_from_request from readthedocs.core.utils.extend import SettingsOverrideObject -from readthedocs.projects.models import Feature, Project +from readthedocs.projects.models import Project class BaseAnalyticsView(APIView): From dd0db1a8fd798d3a4441c005d0114a7ba582e191 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 19 Jan 2021 18:14:43 -0500 Subject: [PATCH 4/4] Update test --- readthedocs/analytics/tests.py | 6 ------ readthedocs/rtd_tests/tests/test_builds.py | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/readthedocs/analytics/tests.py b/readthedocs/analytics/tests.py index c682c268764..faa667ad7eb 100644 --- a/readthedocs/analytics/tests.py +++ b/readthedocs/analytics/tests.py @@ -123,12 +123,6 @@ def test_increase_page_view_count(self): PageView.objects.all().count() == 0 ), 'There\'s no PageView object created yet.' - # Without the feature flag, no PageView is created - self.client.get(self.url, HTTP_HOST=self.host) - assert ( - PageView.objects.all().count() == 0 - ) - # testing for yesterday with mock.patch('readthedocs.analytics.tasks.timezone.now') as mocked_timezone: mocked_timezone.return_value = self.yesterday diff --git a/readthedocs/rtd_tests/tests/test_builds.py b/readthedocs/rtd_tests/tests/test_builds.py index 0c9b29e54a5..e07c9ce7050 100644 --- a/readthedocs/rtd_tests/tests/test_builds.py +++ b/readthedocs/rtd_tests/tests/test_builds.py @@ -73,7 +73,8 @@ def test_build(self, load_config): self.assertEqual(self.mocks.popen.call_count, 1) cmd = self.mocks.popen.call_args_list[0][0] self.assertRegex(cmd[0][0], r'python') - self.assertRegex(cmd[0][1], r'sphinx-build') + self.assertRegex(cmd[0][1], '-m') + self.assertRegex(cmd[0][2], 'sphinx') @mock.patch('readthedocs.doc_builder.config.load_config') def test_build_respects_pdf_flag(self, load_config):