From 0499e578cdd45db656da34cd2d7152c8d88ceb23 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 24 Aug 2023 13:49:22 +0200 Subject: [PATCH] Added /opds/stats route --- cps/opds.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cps/opds.py b/cps/opds.py index 074a9b73..4067712f 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -21,9 +21,10 @@ # along with this program. If not, see . import datetime +import json from urllib.parse import unquote_plus -from flask import Blueprint, request, render_template, make_response, abort +from flask import Blueprint, request, render_template, make_response, abort, Response from flask_login import current_user from flask_babel import get_locale from flask_babel import gettext as _ @@ -412,6 +413,17 @@ def get_metadata_calibre_companion(uuid, library): return "" +@opds.route("/opds/stats") +@requires_basic_auth_if_no_ano +def get_database_stats(): + stat = dict() + stat['books'] = calibre_db.session.query(db.Books).count() + stat['authors'] = calibre_db.session.query(db.Authors).count() + stat['categories'] = calibre_db.session.query(db.Tags).count() + stat['series'] = calibre_db.session.query(db.Series).count() + return Response(json.dumps(stat), mimetype="application/json") + + @opds.route("/opds/thumb_240_240/") @opds.route("/opds/cover_240_240/") @opds.route("/opds/cover_90_90/")