Skip to content

Commit

Permalink
[Fixes🛠️] view count increment typeError - NoneType and int
Browse files Browse the repository at this point in the history
  • Loading branch information
[esekyi] committed Sep 17, 2024
1 parent 8a60f4f commit ea30876
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def __repr__(self):

def increment_view_count(self):
"""Increment the view count without updating the updated_at timestamp."""
if self.view_count is None: # Check if view_count is None
self.view_count = 0 # Initialize to 0 if None
self.view_count += 1
db.session.commit()
# No commit or onupdate manipulation here

0 comments on commit ea30876

Please sign in to comment.