diff --git a/packages/bundle/src/endpoint/index.ts b/packages/bundle/src/endpoint/index.ts index 095b804..a5b59d9 100644 --- a/packages/bundle/src/endpoint/index.ts +++ b/packages/bundle/src/endpoint/index.ts @@ -204,6 +204,15 @@ export default { .first(); video.likes_count = parseInt(likesCount?.count || 0); + + // Count actual plays from database + const playsCount = await database + .count("* as count") + .from("sexy_video_plays") + .where("video_id", video.id) + .first(); + + video.plays_count = parseInt(playsCount?.count || 0); } res.json(videos); @@ -257,6 +266,15 @@ export default { video.likes_count = parseInt(likesCount?.count || 0); + // Count actual plays from database + const playsCount = await database + .count("* as count") + .from("sexy_video_plays") + .where("video_id", video.id) + .first(); + + video.plays_count = parseInt(playsCount?.count || 0); + res.json(video); } catch (error: any) { console.error("Video by slug error:", error); diff --git a/packages/frontend/src/routes/videos/[slug]/+page.svelte b/packages/frontend/src/routes/videos/[slug]/+page.svelte index b7a5a11..5aec13e 100644 --- a/packages/frontend/src/routes/videos/[slug]/+page.svelte +++ b/packages/frontend/src/routes/videos/[slug]/+page.svelte @@ -244,17 +244,16 @@ let showPlayer = $state(false);
- + {#if data.video.plays_count} +
+ + {data.video.plays_count} {data.video.plays_count === 1 ? 'play' : 'plays'} +
+ {/if}
{timeAgo.format(new Date(data.video.upload_date))}
-