Skip to content

Commit c3080a8

Browse files
committed
feat: update progress handling in format_description and history_modal
1 parent 182505c commit c3080a8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/app/helpers.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,23 @@ def format_description(field_name, old_value, new_value, media_type=None): # no
140140

141141
if field_name == "progress" and media_type != MediaTypes.MOVIE.value:
142142
diff = new_value - old_value
143+
diff_abs = abs(diff)
143144

144145
if media_type == MediaTypes.GAME.value:
145146
if diff > 0:
146-
return f"Added {minutes_to_hhmm(diff)} of playtime"
147-
return f"Removed {minutes_to_hhmm(abs(diff))} of playtime"
147+
return f"Added {minutes_to_hhmm(diff_abs)} of playtime"
148+
return f"Removed {minutes_to_hhmm(diff_abs)} of playtime"
148149

149150
unit = (
150151
f"{media_type_config.get_unit(media_type, short=False).lower()}"
151-
f"{pluralize(diff)}"
152+
f"{pluralize(diff_abs)}"
152153
)
153154

154155
verb = media_type_config.get_verb(media_type, past_tense=True).title()
155156
if diff < 0:
156157
verb = "Removed" # Override with "Removed" for negative changes
157158

158-
return f"{verb} {abs(diff)} {unit}"
159+
return f"{verb} {diff_abs} {unit}"
159160

160161
if field_name == "repeats":
161162
verb = media_type_config.get_verb(media_type, past_tense=True)

src/app/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ def history_modal(
574574
delta = new_record.diff_against(old_record)
575575

576576
for change in delta.changes:
577+
if change.field == "progress_changed":
578+
continue
577579
entry["changes"].append(
578580
{
579581
"description": helpers.format_description(
@@ -594,7 +596,7 @@ def history_modal(
594596
for field in history_model._meta.get_fields(): # noqa: SLF001
595597
if (
596598
field.name.startswith("history_")
597-
or field.name in ["id", "modified"]
599+
or field.name in ["id", "progress_changed"]
598600
or not getattr(new_record, field.attname)
599601
):
600602
continue

0 commit comments

Comments
 (0)