Fix tag views redis cache
This commit is contained in:
parent
7fb2f3170c
commit
208a47b41d
|
@ -52,18 +52,20 @@ def list_all():
|
||||||
joinedload(Package.media_license), \
|
joinedload(Package.media_license), \
|
||||||
subqueryload(Package.tags))
|
subqueryload(Package.tags))
|
||||||
|
|
||||||
edited = False
|
ip = request.headers.get("X-Forwarded-For") or request.remote_addr
|
||||||
for tag in qb.tags:
|
if ip is not None:
|
||||||
edited = True
|
edited = False
|
||||||
key = "tag-" + tag.name
|
for tag in qb.tags:
|
||||||
if not has_key(key):
|
edited = True
|
||||||
set_key(key, "true")
|
key = "tag/{}/{}".format(ip, tag.name)
|
||||||
Tag.query.filter_by(id=tag.id).update({
|
if not has_key(key):
|
||||||
"views": Tag.views + 1
|
set_key(key, "true")
|
||||||
})
|
Tag.query.filter_by(id=tag.id).update({
|
||||||
|
"views": Tag.views + 1
|
||||||
|
})
|
||||||
|
|
||||||
if edited:
|
if edited:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
if qb.lucky:
|
if qb.lucky:
|
||||||
package = query.first()
|
package = query.first()
|
||||||
|
|
Loading…
Reference in New Issue