diff options
author | rubenwardy <rw@rubenwardy.com> | 2020-04-21 18:15:13 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2020-04-21 18:15:13 +0100 |
commit | 0620c3e00f66a075f887792c3e40555f3e3627d3 (patch) | |
tree | 61108701dab9c02aca6524727e8d9008f664c6ea | |
parent | a8374ec779aec7e3c5f87a6eb35522d85654d69d (diff) | |
download | cheatdb-0620c3e00f66a075f887792c3e40555f3e3627d3.tar.xz |
Add API to see scores
-rw-r--r-- | app/blueprints/api/endpoints.py | 10 | ||||
-rw-r--r-- | app/flatpages/help/api.md | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/blueprints/api/endpoints.py b/app/blueprints/api/endpoints.py index 3cb2c17..057cb7a 100644 --- a/app/blueprints/api/endpoints.py +++ b/app/blueprints/api/endpoints.py @@ -37,6 +37,16 @@ def packages(): return jsonify(pkgs) +@bp.route("/api/scores/") +def package_scores(): + qb = QueryBuilder(request.args) + query = qb.buildPackageQuery() + + pkgs = [{ "author": package.author.username, "name": package.name, "score": package.score } \ + for package in query.all()] + return jsonify(pkgs) + + @bp.route("/api/packages/<author>/<name>/") @is_package_page def package(package): diff --git a/app/flatpages/help/api.md b/app/flatpages/help/api.md index b141f2c..8387caa 100644 --- a/app/flatpages/help/api.md +++ b/app/flatpages/help/api.md @@ -21,6 +21,7 @@ You can use the `/api/whoami` to check authentication. ### Packages * GET `/api/packages/` - See [Package Queries](#package-queries) +* GET `/api/scores/` - See [Package Queries](#package-queries) * GET `/api/packages/<username>/<name>/` ### Releases |