From 3fd78bd63d56cd7a8f260dc457f1a88b69a71f90 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Fri, 21 Jun 2013 16:01:03 +0200 Subject: [PATCH] [web] Add API method to get the total item count --- beetsplug/web/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 15ef9642a..8b43d9659 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -73,6 +73,12 @@ def all_items(): all_ids = [row[0] for row in rows] return flask.jsonify(item_ids=all_ids) +@app.route('/item/count') +def iten_count(): + with g.lib.transaction() as tx: + rows = tx.query("SELECT COUNT(*) FROM items") + return flask.jsonify({'itemcount': rows[0][0]}) + @app.route('/item//file') def item_file(item_id): item = g.lib.get_item(item_id)