add global count

This commit is contained in:
Yax 2021-02-03 18:31:46 +01:00
parent 0056feaa7f
commit af9bfcdddc

View file

@ -59,11 +59,16 @@ def get_comments_count():
abort(401) abort(401)
url = request.args.get("url", "") url = request.args.get("url", "")
count = ( if url:
Comment.select(Comment) count = (
.where((Comment.url == url) & (Comment.published.is_null(False))) Comment.select(Comment)
.count() .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 = jsonify({"count": count})
r.status_code = 200 r.status_code = 200
except Exception: except Exception: