refresh: take the 100 most stale posts

it doesn't make sense to sample random posts anymore since i don't use
the result of that for picking a post to delete anymore
This commit is contained in:
codl 2017-08-13 11:03:29 +02:00
parent bd574920b4
commit 1a54f5052f
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 1 additions and 7 deletions

View File

@ -164,13 +164,7 @@ def refresh_posts(posts):
def refresh_account(account_id):
account = Account.query.get(account_id)
oldest_post = Post.query.with_parent(account).order_by(db.asc(Post.updated_at)).first()
if not oldest_post:
return []
posts = Post.query.with_parent(account).filter(Post.id != oldest_post.id).order_by(db.func.random()).limit(99).all()
posts.append(oldest_post)
posts = Post.query.with_parent(account).filter(Post.id != oldest_post.id).order_by(db.asc(Post.updated_at)).limit(100).all()
posts = refresh_posts(posts)
account.touch_refresh()