aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints/packages/packages.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-07-15 19:06:00 +0100
committerrubenwardy <rw@rubenwardy.com>2020-07-15 19:06:00 +0100
commit9663e87838dcc040cf0c5df99db1e07b7b56189e (patch)
treeaa662009681581173b35f11cca2cea3115ba0a78 /app/blueprints/packages/packages.py
parent8dd1cd9045bad112d93e58b96332c5dd1b4df996 (diff)
downloadcheatdb-9663e87838dcc040cf0c5df99db1e07b7b56189e.tar.xz
Count tag views
Diffstat (limited to 'app/blueprints/packages/packages.py')
-rw-r--r--app/blueprints/packages/packages.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py
index 90cb72f..8cb9b62 100644
--- a/app/blueprints/packages/packages.py
+++ b/app/blueprints/packages/packages.py
@@ -24,6 +24,7 @@ from . import bp
from app.models import *
from app.querybuilder import QueryBuilder
from app.tasks.importtasks import importRepoScreenshot, updateMetaFromRelease
+from app.rediscache import has_key, set_key
from app.utils import *
from flask_wtf import FlaskForm
@@ -51,6 +52,19 @@ def list_all():
joinedload(Package.media_license), \
subqueryload(Package.tags))
+ edited = False
+ for tag in qb.tags:
+ edited = True
+ key = "tag-" + tag.name
+ if not has_key(key):
+ set_key(key, "true")
+ Tag.query.filter_by(id=tag.id).update({
+ "views": Tag.views + 1
+ })
+
+ if edited:
+ db.session.commit()
+
if qb.lucky:
package = query.first()
if package: