summaryrefslogtreecommitdiffhomepage
path: root/apioforum/forum.py
diff options
context:
space:
mode:
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r--apioforum/forum.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index f25d0da..e5d91f9 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -12,7 +12,14 @@ bp = Blueprint("forum", __name__, url_prefix="/")
@bp.route("/")
def view_forum():
db = get_db()
- threads = db.execute("SELECT * FROM threads ORDER BY updated DESC;").fetchall()
+ threads = db.execute(
+ """SELECT threads.id, threads.title, threads.creator, threads.created,
+ threads.updated, count(posts.id) as num_replies
+ FROM threads
+ INNER JOIN posts ON posts.thread = threads.id
+ GROUP BY threads.id
+ ORDER BY threads.updated DESC;
+ """).fetchall()
return render_template("view_forum.html",threads=threads)
@bp.route("/create_thread",methods=("GET","POST"))