diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-01-29 01:43:21 +0000 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2019-01-29 01:43:21 +0000 |
commit | 7810bb54e0fea0f9452423d89e13ab0c87f767f1 (patch) | |
tree | 7885ed204f767eb9c49f1f16c51cdbd2c7b5374d /app | |
parent | 2844773e4d05b3453fb90e131035a1639f05cd84 (diff) | |
download | cheatdb-7810bb54e0fea0f9452423d89e13ab0c87f767f1.tar.xz |
Add download counter to home page
Diffstat (limited to 'app')
-rw-r--r-- | app/templates/index.html | 2 | ||||
-rw-r--r-- | app/views/__init__.py | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/templates/index.html b/app/templates/index.html index 210cc84..e11b3c8 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -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> --> diff --git a/app/views/__init__.py b/app/views/__init__.py index 303ed2a..c99ca03 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -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 |