Skip to content

Commit

Permalink
show comment count on video
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramminCat committed Aug 19, 2024
1 parent 39a1b66 commit f7e694b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion templates/displayshort.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="videoSidebar__button" onclick="opencomments(this)">
<span class="material-icons"> message </span>
<p>23</p>
<p>{{ short.id|get_comment_count }}</p>
</div>

<div class="videoSidebar__button" onclick="share(this)">
Expand Down

0 comments on commit f7e694b

Please sign in to comment.