Skip to content

Commit 54bda72

Browse files
dannyvfilmsclaude
andcommitted
Restore helpers.seconds_to_hm, accidentally deleted by the collection-completeness commit
74bb993 ("Add partial-collection completeness to the Collection page", fixes #976) deleted seconds_to_hm from helpers.py as unrelated collateral damage, breaking every call site that formats a podcast episode duration (podcast API/views, stats aggregator, stats_podcast) since it's the shared formatter 3e77176 consolidated seven duplicate implementations into. Restoring the original implementation rather than re-duplicating it at each call site. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent ef9c346 commit 54bda72

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/app/helpers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ def minutes_to_hhmm(total_minutes):
7575
return f"{hours}h {minutes:02d}min"
7676

7777

78+
def seconds_to_hm(total_seconds):
79+
"""Convert a duration in seconds to "1h 9m", or to "46m" under an hour.
80+
81+
Returns "" for a missing or zero duration.
82+
"""
83+
if not total_seconds:
84+
return ""
85+
hours = total_seconds // 3600
86+
minutes = (total_seconds % 3600) // 60
87+
return f"{hours}h {minutes}m" if hours else f"{minutes}m"
88+
89+
7890
def has_real_image(image):
7991
"""Return whether the value is a usable artwork URL."""
8092
return bool(image and image != settings.IMG_NONE)

0 commit comments

Comments
 (0)