Skip to content

Commit

Permalink
fix: Bad Recipe Rating Calc Preventing App Startup (#3475)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Apr 16, 2024
1 parent 6e1112c commit 46f1ad7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mealie/db/models/recipe/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ def receive_description(target: RecipeModel, value: str, oldvalue, initiator):
@event.listens_for(RecipeModel, "before_update")
def calculate_rating(mapper, connection, target: RecipeModel):
session = object_session(target)
if not session:
if not (session and session.is_modified(target, "rating")):
return

if session.is_modified(target, "rating"):
history = get_history(target, "rating")
old_value = history.deleted[0] if history.deleted else None
new_value = history.added[0] if history.added else None
history = get_history(target, "rating")
old_value = history.deleted[0] if history.deleted else None
new_value = history.added[0] if history.added else None
if old_value == new_value:
return

Expand Down

0 comments on commit 46f1ad7

Please sign in to comment.