From f7e694bafb22902dcee8dd383cb9511b9f891db6 Mon Sep 17 00:00:00 2001 From: snowcatridge10 <72707293+ProgramminCat@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:25:32 -0400 Subject: [PATCH] show comment count on video --- app.py | 9 +++++++++ templates/displayshort.html | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 5811d2a..12ddc8c 100644 --- a/app.py +++ b/app.py @@ -85,6 +85,15 @@ def get_comments(vid): return myresult +@app.template_filter('get_comment_count') +def get_comment_count(vid): + cursor = mysql.connection.cursor() + + cursor.execute("SELECT count(*) comment_count FROM `vidzy`.`comments` WHERE short_id = %s;", (vid,)) + comment_count = int(cursor.fetchall()[0]["comment_count"]) + + return comment_count + @app.template_filter('get_user_info') def get_user_info(userid): mycursor = mysql.connection.cursor() diff --git a/templates/displayshort.html b/templates/displayshort.html index e0036a2..9b4754e 100644 --- a/templates/displayshort.html +++ b/templates/displayshort.html @@ -12,7 +12,7 @@