mirror of
https://github.com/codl/forget
synced 2025-01-22 11:54:09 +01:00
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:
parent
bd574920b4
commit
1a54f5052f
8
tasks.py
8
tasks.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user