Skip to content
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

Merged
merged 6 commits into from
May 13, 2024

Conversation

Johnetordoff
Copy link
Contributor

Purpose

Fix some signals code that wasn't covered by tests.

Changes

  • squish some ORM logic to avoid errors

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

@@ -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)
Copy link
Contributor

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

@@ -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()
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

@Johnetordoff Johnetordoff marked this pull request as ready for review May 13, 2024 14:47
Copy link
Contributor

@jwalz jwalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny nit

addons/base/views.py Outdated Show resolved Hide resolved
addons/base/views.py Outdated Show resolved Hide resolved
Johnetordoff and others added 2 commits May 13, 2024 11:03
Co-authored-by: Jon Walz <jon@cos.io>
Co-authored-by: Jon Walz <jon@cos.io>
@jwalz jwalz merged commit 2d8e4c1 into CenterForOpenScience:develop May 13, 2024
6 checks passed
Johnetordoff pushed a commit to Johnetordoff/osf.io that referenced this pull request May 13, 2024
 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants