-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store Pageviews in DB #6121
Store Pageviews in DB #6121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good first approach. It needs to be cleaned up a bit though with the modeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks quite close to being ready. Just a few places where it can be cleaned up or simplified.
@@ -210,6 +211,14 @@ def get(self, request, format=None): | |||
'version_supported': version.supported, | |||
} | |||
|
|||
# increase the page view count | |||
page_slug = request.GET.get('page', 'index') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should likely not default to index
, no? If we don't have a page
, we probably shouldn't be storing anything, or some other string like rtd-unknown-page
, not index
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen any real examples where the page parameter is blank. It is index
for the root and even with the dirhtml builder it uses the subdirectory name. I'll add a simple if page_slug
check.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still useful, but I want to wait until our DB load calms down a bit before adding additional load to it. |
- Added a periodic task to remove old pageviews - Show aggregated traffic on the admin view
I refactored this and brought it to a merge-ready state.
I am interested to see what this does to our database as it will add a (simple) write query in a celery task on every Footer API call. Screenshot |
@@ -977,15 +975,6 @@ class RegexAutomationRuleUpdate(RegexAutomationRuleMixin, UpdateView): | |||
pass | |||
|
|||
|
|||
@login_required | |||
def search_analytics_view(request, project_slug): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what this view is. It doesn't appear to be used or valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I'm curious if we should be keeping the pageview data in the search
app, but I think it's fine for now?
I'm also super curious what this will do to our celery queues and DB, but I think it shouldn't be too much. A simple update isn't a ton of work, but we'll see :)
The nice thing is we can always limit the celery workers or turn them off in some fashion, so we have a reasonable escape hatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more tidbits.
readthedocs/search/tasks.py
Outdated
|
||
This is intended to run from a periodic task daily. | ||
""" | ||
thirty_days_ago = timezone.now().date() - timezone.timedelta(days=30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably log something, so we know it's running properly.
readthedocs/search/tasks.py
Outdated
|
||
|
||
@app.task(queue='web') | ||
def increase_page_view_count(project_slug, version_slug, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if running this as a task is actually a good deal slower then running it in the footer itself? We already have the Project & Version object in the footer, and not we're adding additional queries for them here. They should be fast queries, but definitely additional load.
I guess the proper solution is to cache these lookups, which we can do later if it's an issue.
I had this thought myself. I don't have a strong opinion either way. I'd be fine moving it into the Project app or a case could even be made for the Build app as it is Version specific. The case for the search app is that that is where the data is most useful: for ordering search results. However, as we have a page in the project admin, maybe that isn't the right place. I'd rather get it into the right place the first time it's deployed. Moving it could be a bit of a pain. If you have an opinion, let's get that in. |
Well, arguably the Versions should be in the Project app instead of Builds, so we're already in a confusing place to start :) I think we put them in Search originally because we wanted to use them to weight search results by pageview count. I think it probably makes sense for them to be in their own app, something like |
Ah, we already have an |
@davidfischer it would be good to get this patched up and shipped this week if possible. |
I'll take a look at it But I can't make any promises I might need Some
help
…On Mon, May 18, 2020, 4:59 PM Eric Holscher ***@***.***> wrote:
@davidfischer <https://github.com/davidfischer> it would be good to get
this patched up and shipped this week if possible.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6121 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO3EPOCEY7GAQKLF2L5C67LRSGOTXANCNFSM4ISFNKXA>
.
|
I moved the pageview modeling from the search app to the analytics app. This is ready for a full review. |
Looks good 🎉 |
Related: #5968