From d86c53527bb9712ecb5f856126fa816c8608689a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 23 Aug 2018 16:21:00 -0700 Subject: [PATCH] Fix blueprints/list and blueprints/changes to return the correct total (cherry picked from commit ec908fcd2a0239650af118dae1d2fbd38c7af6e7) --- src/pylorax/api/v0.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pylorax/api/v0.py b/src/pylorax/api/v0.py index f075ce1e..1904512a 100644 --- a/src/pylorax/api/v0.py +++ b/src/pylorax/api/v0.py @@ -1038,8 +1038,9 @@ def v0_api(api): return jsonify(status=False, errors=[{"id": BAD_LIMIT_OR_OFFSET, "msg": str(e)}]), 400 with api.config["GITLOCK"].lock: - blueprints = take_limits([f[:-5] for f in list_branch_files(api.config["GITLOCK"].repo, branch)], offset, limit) - return jsonify(blueprints=blueprints, limit=limit, offset=offset, total=len(blueprints)) + blueprints = [f[:-5] for f in list_branch_files(api.config["GITLOCK"].repo, branch)] + limited_blueprints = take_limits(blueprints, offset, limit) + return jsonify(blueprints=limited_blueprints, limit=limit, offset=offset, total=len(blueprints)) @api.route("/api/v0/blueprints/info", defaults={'blueprint_names': ""}) @api.route("/api/v0/blueprints/info/") @@ -1137,12 +1138,13 @@ def v0_api(api): try: with api.config["GITLOCK"].lock: - commits = take_limits(list_commits(api.config["GITLOCK"].repo, branch, filename), offset, limit) + commits = list_commits(api.config["GITLOCK"].repo, branch, filename) + limited_commits = take_limits(list_commits(api.config["GITLOCK"].repo, branch, filename), offset, limit) except Exception as e: errors.append({"id": BLUEPRINTS_ERROR, "msg": "%s: %s" % (blueprint_name, str(e))}) log.error("(v0_blueprints_changes) %s", str(e)) else: - blueprints.append({"name":blueprint_name, "changes":commits, "total":len(commits)}) + blueprints.append({"name":blueprint_name, "changes":limited_commits, "total":len(commits)}) blueprints = sorted(blueprints, key=lambda r: r["name"].lower())