-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add new fields to UserVisit #25
Add new fields to UserVisit #25
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.
Good idea - I've added some basic edit suggestions just to bring it inline with our other libs.
@mboboc thanks for this update - good idea. Once the linting issues are fixed (and feedback applied) will be happy to merge it. |
@mboboc just a couple of linting issues to fix - if you have the poetry environment set up you should be able to run |
@hugorodgerbrown Got it, I'll update the code soon (today I hope). |
The linting errors are from the
In order to reproduce the error locally I had to update the django-user-visit/.pre-commit-config.yaml Lines 19 to 21 in d78ded9
with
Saw you fixed it in #26. |
Ah - yes, we're migrating all our repos from flake8 to ruff, so those errors don't matter in the long run. I'll merge your changes in and fix on master. |
Although, just looking at this - the migrations need to be recreated, as they are now out of sync with the fields (default, null). |
re. flake8 - if you "sync upstream" on your repo that should bring in the new linting? |
After you merge #26 on master, I could bring the changes to this branch. This should solve it. |
@hugorodgerbrown I merged the master branch into this branch, it should be okay now. |
@mboboc merged - I'll cut a release in due course - and will add you to the changelog as the author. |
What about the existing entries of UserVisits? |
Hi @radudum10 - yes, these will need backfilling. Our (hard won) experience with large tables and data migrations is that they can easily block a release or lock up a website at release time, and so our pattern for these types of releases is a management command that can a.) be aborted, and b.) be run out of hours. There is a bunch of work to be done before the release as this is a major one (upgrading Django / Python classifiers), so I'll add in the management command and instructions on the upgrade. |
I have released this as v2.0. There is a bug in the management command (:facepalm:) which means you have to run it with the |
This is an optimization to allow filtering by
os
/browser
/device
directly in the database.django-user-visit
is very useful in order to track user visits for websites, however, there are 2 main things happening when using this library:ua_string
in PythonBecause the user agent is stored as a string and the corresponding parsing functions are implemented in Python, the filtering is fated to be done in Python resulting in poor performance. Also, because the UserVisit table gets populated fast, the waiting times for filtering goes up fast too.
The straightforward solution is to store the string as separate fields inside the database.