Add download counter to home page

This commit is contained in:
rubenwardy 2019-01-29 01:43:21 +00:00
parent 2844773e4d
commit 7810bb54e0
2 changed files with 4 additions and 2 deletions

@ -51,7 +51,7 @@ Welcome
<div class="text-center">
<small>
CDB has {{ count }} packages available to download.
CDB has {{ count }} packages, with a total of {{ downloads }} downloads.
</small>
</div>
<!-- </main> -->

@ -22,6 +22,7 @@ from app.models import *
import flask_menu as menu
from werkzeug.contrib.cache import SimpleCache
from urllib.parse import urlparse
from sqlalchemy.sql.expression import func
cache = SimpleCache()
@app.template_filter()
@ -53,7 +54,8 @@ def home_page():
pop_mod = query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score)).limit(8).all()
pop_gam = query.filter_by(type=PackageType.GAME).order_by(db.desc(Package.score)).limit(4).all()
pop_txp = query.filter_by(type=PackageType.TXP).order_by(db.desc(Package.score)).limit(4).all()
return render_template("index.html", count=count, \
downloads = db.session.query(func.sum(PackageRelease.downloads)).first()[0]
return render_template("index.html", count=count, downloads=downloads, \
new=new, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam)
from . import users, packages, meta, threads, api