-
Notifications
You must be signed in to change notification settings - Fork 331
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
[ENG-5140] #2 Update get_auth for GV and readability #10613
[ENG-5140] #2 Update get_auth for GV and readability #10613
Conversation
addons/base/views.py
Outdated
@@ -697,22 +697,23 @@ def osfstoragefile_update_view_analytics(self, auth, fileversion): | |||
|
|||
@file_signals.file_viewed.connect | |||
def osfstoragefile_viewed_update_metrics(self, auth, fileversion): | |||
resource = BaseFileNode.objects.get(versions__id=fileversion.id).target | |||
file = BaseFileNode.objects.get(versions__id=fileversion.id) |
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.
still a problem with get
possibly returning multiple results
addons/base/views.py
Outdated
@@ -697,22 +697,23 @@ def osfstoragefile_update_view_analytics(self, auth, fileversion): | |||
|
|||
@file_signals.file_viewed.connect | |||
def osfstoragefile_viewed_update_metrics(self, auth, fileversion): | |||
resource = BaseFileNode.objects.get(versions__id=fileversion.id).target | |||
file = BaseFileNode.objects.filter(versions__id=fileversion.id).last() |
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.
.last
is guaranteed to not throw a MultipleObjectsReturned
error, but isn't guaranteed to deliver the correct FileNode
object. Would it be possible to include it in the file_signals.file_viewed.send
call instead?
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.
Won't all the versions have the same BaseFIleNode though? I only retrieve the version, not the full node.
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.
FileVersions help dedupe information, so one FileVersion can belong to many BaseFileNodes
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.
One tiny nit
Co-authored-by: Jon Walz <jon@cos.io>
Co-authored-by: Jon Walz <jon@cos.io>
into gv-files-provider-waffle * 'develop' of https://github.com/CenterForOpenScience/osf.io: [ENG-5140] #2 Update get_auth for GV and readability (CenterForOpenScience#10613)
Purpose
Fix some signals code that wasn't covered by tests.
Changes
QA Notes
Please make verification statements inspired by your code and what your code touches.
What are the areas of risk?
Any concerns/considerations/questions that development raised?
Documentation
Side Effects
Ticket