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},
|
||||
).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:
|
||||
disk = shutil.disk_usage(settings.download_path)
|
||||
download_bytes = sum(
|
||||
@@ -164,6 +173,7 @@ def get_stats(
|
||||
"total_rewatches": avg_completion["total_rewatches"] or 0,
|
||||
"rewatched_videos": avg_completion["rewatched_videos"] 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],
|
||||
"peak_hours": [dict(r) for r in peak_hours],
|
||||
"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>
|
||||
|
||||
{/* 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="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="Total liked" value={(data.total_liked || 0).toLocaleString()} sub="videos" />
|
||||
</div>
|
||||
|
||||
{/* 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
|
||||
label="Avg completion"
|
||||
value={`${data.avg_completion_percent ?? 0}%`}
|
||||
@@ -89,6 +88,11 @@ export default function Stats() {
|
||||
value={(data.finished_count || 0).toLocaleString()}
|
||||
sub="watched ≥75%"
|
||||
/>
|
||||
<StatCard
|
||||
label="In progress"
|
||||
value={(data.started_count || 0).toLocaleString()}
|
||||
sub="started, not finished"
|
||||
/>
|
||||
<StatCard
|
||||
label="Bailed early"
|
||||
value={(data.bailed_count || 0).toLocaleString()}
|
||||
@@ -99,6 +103,11 @@ export default function Stats() {
|
||||
value={(data.rewatched_videos || 0).toLocaleString()}
|
||||
sub={`${data.total_rewatches || 0} total rewatches`}
|
||||
/>
|
||||
<StatCard
|
||||
label="Total liked"
|
||||
value={(data.total_liked || 0).toLocaleString()}
|
||||
sub="videos"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Activity chart */}
|
||||
|
||||
Reference in New Issue
Block a user