This commit is contained in:
Aevann1 2021-09-05 11:37:05 +02:00
parent 13773f28fa
commit b26640ed20
6 changed files with 9 additions and 13 deletions

View file

@ -361,13 +361,11 @@ def changelog(v):
@auth_desired
def random_post(v):
x = g.db.query(Submission).filter(Submission.deleted_utc == 0, Submission.is_banned == False)
total = x.count()
n = random.randint(0, total - 1)
n = random.randint(1, total - 2)
post = x.offset(n).limit(1).first()
post = x.all()[n]
return redirect(f"/post/{post.id}")
@cache.memoize(timeout=86400)