From bc2292b0e8c89d05e6b85e403e47509a728cc4da Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Wed, 3 Feb 2021 18:31:46 +0100 Subject: [PATCH] add global count --- stacosys/interface/api.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stacosys/interface/api.py b/stacosys/interface/api.py index 7b104e7..5c6151a 100644 --- a/stacosys/interface/api.py +++ b/stacosys/interface/api.py @@ -59,11 +59,16 @@ def get_comments_count(): abort(401) url = request.args.get("url", "") - count = ( - Comment.select(Comment) - .where((Comment.url == url) & (Comment.published.is_null(False))) - .count() - ) + if url: + count = ( + Comment.select(Comment) + .where((Comment.url == url) & (Comment.published.is_null(False))) + .count() + ) + else: + count = ( + Comment.select(Comment).where(Comment.published.is_null(False)).count() + ) r = jsonify({"count": count}) r.status_code = 200 except Exception: