fix: query actual likes count from database instead of cached field
Some checks failed
Build and Push Docker Image to Gitea / build-and-push (push) Has been cancelled

The likes_count field on videos was becoming inaccurate due to the manually
maintained counter getting out of sync with actual like records. Now we count
likes directly from the sexy_video_likes table for accurate counts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 19:17:32 +01:00
parent 2c010c98d0
commit ac09d544d4

View File

@@ -195,6 +195,15 @@ export default {
.first();
video.movie = movie;
}
// Count actual likes from database
const likesCount = await database
.count("* as count")
.from("sexy_video_likes")
.where("video_id", video.id)
.first();
video.likes_count = parseInt(likesCount?.count || 0);
}
res.json(videos);
@@ -239,6 +248,15 @@ export default {
video.movie = movie;
}
// Count actual likes from database
const likesCount = await database
.count("* as count")
.from("sexy_video_likes")
.where("video_id", video.id)
.first();
video.likes_count = parseInt(likesCount?.count || 0);
res.json(video);
} catch (error: any) {
console.error("Video by slug error:", error);