Skip to content

Commit c8bbcdc

Browse files
authored
Merge pull request #7097 from readthedocs/add-pageview-settings
Add a setting for storing pageviews
2 parents 82aedba + 14dc98d commit c8bbcdc

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

readthedocs/api/v2/views/footer_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from readthedocs.builds.models import Version
1717
from readthedocs.core.utils.extend import SettingsOverrideObject
1818
from readthedocs.projects.constants import MKDOCS, SPHINX_HTMLDIR
19-
from readthedocs.projects.models import Project
19+
from readthedocs.projects.models import Project, Feature
2020
from readthedocs.projects.version_handling import (
2121
highest_version,
2222
parse_version_failsafe,
@@ -225,7 +225,7 @@ def get(self, request, format=None):
225225

226226
# increase the page view count for the given page
227227
page_slug = request.GET.get('page', '')
228-
if page_slug:
228+
if page_slug and project.has_feature(Feature.STORE_PAGEVIEWS):
229229
increase_page_view_count.delay(
230230
project_slug=context['project'].slug,
231231
version_slug=context['version'].slug,

readthedocs/projects/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ def add_features(sender, **kwargs):
14681468
FORCE_SPHINX_FROM_VENV = 'force_sphinx_from_venv'
14691469
LIST_PACKAGES_INSTALLED_ENV = 'list_packages_installed_env'
14701470
VCS_REMOTE_LISTING = 'vcs_remote_listing'
1471+
STORE_PAGEVIEWS = 'store_pageviews'
14711472

14721473
FEATURES = (
14731474
(USE_SPHINX_LATEST, _('Use latest version of Sphinx')),
@@ -1557,6 +1558,10 @@ def add_features(sender, **kwargs):
15571558
VCS_REMOTE_LISTING,
15581559
_('Use remote listing in VCS (e.g. git ls-remote) if supported for sync versions'),
15591560
),
1561+
(
1562+
STORE_PAGEVIEWS,
1563+
_('Store pageviews for this project'),
1564+
),
15601565
)
15611566

15621567
projects = models.ManyToManyField(

readthedocs/rtd_tests/tests/test_footer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class TestFooterPerformance(APITestCase):
418418

419419
# The expected number of queries for generating the footer
420420
# This shouldn't increase unless we modify the footer API
421-
EXPECTED_QUERIES = 13
421+
EXPECTED_QUERIES = 14
422422

423423
def setUp(self):
424424
self.pip = Project.objects.get(slug='pip')

readthedocs/settings/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# pylint: disable=missing-docstring
22

3-
import getpass
43
import os
54
import subprocess
65

readthedocs/templates/projects/project_traffic_analytics.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
{% block project_edit_content %}
1414
<h3>{% trans "Top viewed pages of the past month" %}</h3>
15+
<p>
16+
This beta feature can be enabled by <a href="mailto:{{ SUPPORT_EMAIL }}">asking support</a>.
17+
</p>
1518
<div class="module-list">
1619
<div class="module-list-wrapper">
1720
<ul class="long-list-overflow">

0 commit comments

Comments
 (0)