fix(channels): the Length column shows the sum alone

The "+N without length" line did not fit the 4.5 rem column (88 px of
text in a 56 px cell) and spilled into Tags. The owner wants no such
line there: the cell shows the summed hours, and the channel list no
longer sends a count nothing reads. A playlist's total keeps it.
This commit is contained in:
2026-11-08 00:10:28 +01:00
parent 4d058cba81
commit 55cbbfb6e4
9 changed files with 25 additions and 22 deletions
+4 -8
View File
@@ -44,8 +44,8 @@ def channel_titles(db: Session, ids: set[str]) -> dict[str, str]:
def channel_aggregates(channel_ids: list[str]) -> Select:
"""Per-channel stored count, last upload, total duration and the live videos the total cannot
hold (`Video.live_without_length`), in one grouped pass. Every column it
"""Per-channel stored count, last upload and total duration (the lengths it knows: a video with
none is left out, `Video.length_seconds`), in one grouped pass. Every column it
reads is in `ix_videos_channel_pub_cover` (migration 0095), so Postgres answers it from the index
alone; a test holds that (test_channel_list_index_only)."""
return (
@@ -54,18 +54,14 @@ def channel_aggregates(channel_ids: list[str]) -> Select:
func.count(Video.id),
func.max(Video.published_at),
func.coalesce(func.sum(Video.length_seconds), 0),
func.count().filter(Video.live_without_length),
)
.where(Video.channel_id.in_(channel_ids))
.group_by(Video.channel_id)
)
def aggregates(
db: Session, channel_ids: list[str]
) -> list[tuple[str, int, datetime | None, int, int]]:
"""`channel_aggregates`, run: (channel id, stored videos, last upload, total seconds, live
videos without a length)."""
def aggregates(db: Session, channel_ids: list[str]) -> list[tuple[str, int, datetime | None, int]]:
"""`channel_aggregates`, run: (channel id, stored videos, last upload, total seconds)."""
if not channel_ids:
return []
return list(db.execute(channel_aggregates(channel_ids)).tuples())