Add started_count to stats (videos in progress, not yet finished)
Tracks watch_progress_seconds > 0 AND watched = 0. Shown as "In progress" card in the engagement row alongside finished/bailed/rewatched. Total liked moved to engagement row, top row condensed to 3 cards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,15 @@ def get_stats(
|
|||||||
{"uid": uid},
|
{"uid": uid},
|
||||||
).mappings().first()
|
).mappings().first()
|
||||||
|
|
||||||
|
started_count = db.execute(
|
||||||
|
text("""
|
||||||
|
SELECT COUNT(*) AS n FROM user_videos
|
||||||
|
WHERE user_id = :uid AND watched = 0
|
||||||
|
AND watch_progress_seconds > 0
|
||||||
|
"""),
|
||||||
|
{"uid": uid},
|
||||||
|
).mappings().first()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
disk = shutil.disk_usage(settings.download_path)
|
disk = shutil.disk_usage(settings.download_path)
|
||||||
download_bytes = sum(
|
download_bytes = sum(
|
||||||
@@ -164,6 +173,7 @@ def get_stats(
|
|||||||
"total_rewatches": avg_completion["total_rewatches"] or 0,
|
"total_rewatches": avg_completion["total_rewatches"] or 0,
|
||||||
"rewatched_videos": avg_completion["rewatched_videos"] or 0,
|
"rewatched_videos": avg_completion["rewatched_videos"] or 0,
|
||||||
"total_liked": liked_count["n"] or 0,
|
"total_liked": liked_count["n"] or 0,
|
||||||
|
"started_count": started_count["n"] or 0,
|
||||||
"top_categories": [dict(r) for r in top_categories],
|
"top_categories": [dict(r) for r in top_categories],
|
||||||
"peak_hours": [dict(r) for r in peak_hours],
|
"peak_hours": [dict(r) for r in peak_hours],
|
||||||
"taste_profile": [dict(r) for r in taste_profile],
|
"taste_profile": [dict(r) for r in taste_profile],
|
||||||
|
|||||||
@@ -70,15 +70,14 @@ export default function Stats() {
|
|||||||
<h1 className="font-display font-bold text-2xl text-white">Stats</h1>
|
<h1 className="font-display font-bold text-2xl text-white">Stats</h1>
|
||||||
|
|
||||||
{/* Top numbers */}
|
{/* Top numbers */}
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3">
|
||||||
<StatCard label="Total watched" value={data.total_watched.toLocaleString()} sub={fmt(data.total_watch_seconds) + " total"} />
|
<StatCard label="Total watched" value={data.total_watched.toLocaleString()} sub={fmt(data.total_watch_seconds) + " total"} />
|
||||||
<StatCard label="This week" value={data.this_week.count} sub={fmt(data.this_week.seconds)} />
|
<StatCard label="This week" value={data.this_week.count} sub={fmt(data.this_week.seconds)} />
|
||||||
<StatCard label="This month" value={data.this_month.count} sub={fmt(data.this_month.seconds)} />
|
<StatCard label="This month" value={data.this_month.count} sub={fmt(data.this_month.seconds)} />
|
||||||
<StatCard label="Total liked" value={(data.total_liked || 0).toLocaleString()} sub="videos" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Engagement row */}
|
{/* Engagement row */}
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">
|
||||||
<StatCard
|
<StatCard
|
||||||
label="Avg completion"
|
label="Avg completion"
|
||||||
value={`${data.avg_completion_percent ?? 0}%`}
|
value={`${data.avg_completion_percent ?? 0}%`}
|
||||||
@@ -89,6 +88,11 @@ export default function Stats() {
|
|||||||
value={(data.finished_count || 0).toLocaleString()}
|
value={(data.finished_count || 0).toLocaleString()}
|
||||||
sub="watched ≥75%"
|
sub="watched ≥75%"
|
||||||
/>
|
/>
|
||||||
|
<StatCard
|
||||||
|
label="In progress"
|
||||||
|
value={(data.started_count || 0).toLocaleString()}
|
||||||
|
sub="started, not finished"
|
||||||
|
/>
|
||||||
<StatCard
|
<StatCard
|
||||||
label="Bailed early"
|
label="Bailed early"
|
||||||
value={(data.bailed_count || 0).toLocaleString()}
|
value={(data.bailed_count || 0).toLocaleString()}
|
||||||
@@ -99,6 +103,11 @@ export default function Stats() {
|
|||||||
value={(data.rewatched_videos || 0).toLocaleString()}
|
value={(data.rewatched_videos || 0).toLocaleString()}
|
||||||
sub={`${data.total_rewatches || 0} total rewatches`}
|
sub={`${data.total_rewatches || 0} total rewatches`}
|
||||||
/>
|
/>
|
||||||
|
<StatCard
|
||||||
|
label="Total liked"
|
||||||
|
value={(data.total_liked || 0).toLocaleString()}
|
||||||
|
sub="videos"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Activity chart */}
|
{/* Activity chart */}
|
||||||
|
|||||||
Reference in New Issue
Block a user