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

Add view counters to trips and user profiles #219

Merged
merged 6 commits into from
Dec 18, 2023
Merged

Add view counters to trips and user profiles #219

merged 6 commits into from
Dec 18, 2023

Conversation

anorthall
Copy link
Owner

Add view counters to trips and user profiles, which are only viewable by the user that created the object.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

PR Type: Enhancement

PR Summary: The pull request introduces view counters for trips and user profiles, ensuring that these counters are only incremented by views from other users and not by the creators themselves. It includes model updates, view logic to handle the incrementing of view counts, and migrations to add the necessary fields to the database.

General suggestions:

  • Ensure that the control flow changes in the get_trips_context function are intentional and correctly handle the EmptyPage exception scenario.
  • Consider refactoring the add_view method to maintain separation of concerns, possibly by moving the user check logic to the view or service layer.
  • Review the implementation to prevent potential double counting of views, especially where bulk_update_view_count is called in multiple places.
  • Reevaluate the placement of the add_profile_view method call within the setup method of the UserProfile view to align with the typical Django view lifecycle.
  • Add a guard clause in the bulk_update_view_count function to gracefully handle the case where the trips iterable is empty.

Your trial expires on December 25, 2023. Please email tim@sourcery.ai to continue using Sourcery ✨

app/logger/services.py Show resolved Hide resolved
app/logger/models/trip.py Show resolved Hide resolved
app/logger/views/userprofile.py Show resolved Hide resolved
app/logger/services.py Show resolved Hide resolved
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7bf51df) 86.65% compared to head (9d6058a) 86.74%.

❗ Current head 9d6058a differs from pull request most recent head bff5326. Consider uploading reports for the commit bff5326 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
+ Coverage   86.65%   86.74%   +0.08%     
==========================================
  Files          89       89              
  Lines        4332     4360      +28     
  Branches      564      568       +4     
==========================================
+ Hits         3754     3782      +28     
  Misses        482      482              
  Partials       96       96              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anorthall anorthall merged commit 6a4dceb into main Dec 18, 2023
5 checks passed
@anorthall anorthall deleted the view-count branch December 18, 2023 11:35
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.

1 participant