Commits

Uwe L. Korn committed 8a4b850

[web] Add API method to get the total item count

  • Participants
  • Parent commits 9541a7c

Comments (0)

Files changed (1)

File beetsplug/web/__init__.py

     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/<int:item_id>/file')
 def item_file(item_id):
     item = g.lib.get_item(item_id)