From 26abe9275cc9931246c7758009f94e91b8da2b98 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 31 May 2023 17:29:20 +0100 Subject: [PATCH] Promote featured packages in the client --- app/blueprints/api/endpoints.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/blueprints/api/endpoints.py b/app/blueprints/api/endpoints.py index b83118b9..f98a34de 100644 --- a/app/blueprints/api/endpoints.py +++ b/app/blueprints/api/endpoints.py @@ -75,6 +75,18 @@ def packages(): pkgs = qb.convertToDictionary(query.all()) if "engine_version" in request.args or "protocol_version" in request.args: pkgs = [package for package in pkgs if package.get("release")] + + # Promote featured packages + if "sort" not in request.args and "order" not in request.args: + featured_lut = set() + featured = qb.convertToDictionary(query.filter(Package.tags.any(name="featured")).all()) + for pkg in featured: + featured_lut.add(f"{pkg['author']}/{pkg['name']}") + pkg["short_description"] = "Featured. " + pkg["short_description"] + + not_featured = [pkg for pkg in pkgs if f"{pkg['author']}/{pkg['name']}" not in featured_lut] + pkgs = featured + not_featured + return jsonify(pkgs)