Add more info to /api/homepage/

This commit is contained in:
rubenwardy 2021-11-25 10:35:31 +00:00
parent f714d809f8
commit 41e0e65a6b

@ -13,6 +13,7 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import List
from flask import request, jsonify, current_app from flask import request, jsonify, current_app
from flask_login import current_user, login_required from flask_login import current_user, login_required
@ -431,8 +432,8 @@ def homepage():
downloads_result = db.session.query(func.sum(Package.downloads)).one_or_none() downloads_result = db.session.query(func.sum(Package.downloads)).one_or_none()
downloads = 0 if not downloads_result or not downloads_result[0] else downloads_result[0] downloads = 0 if not downloads_result or not downloads_result[0] else downloads_result[0]
def mapPackages(packages): def mapPackages(packages: List[Package]):
return [pkg.getAsDictionaryKey() for pkg in packages] return [pkg.getAsDictionaryShort(current_app.config["BASE_URL"]) for pkg in packages]
return jsonify({ return jsonify({
"count": count, "count": count,