mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
move content deletion to be earlier in the daily maintenance script
This commit is contained in:
parent
2c362e32f4
commit
64a6180a13
1 changed files with 13 additions and 10 deletions
23
app/cli.py
23
app/cli.py
|
@ -191,6 +191,19 @@ def register(app):
|
|||
tag.post_count = post_count
|
||||
db.session.commit()
|
||||
|
||||
# Delete soft-deleted content after 7 days
|
||||
for post_reply in PostReply.query.filter(PostReply.deleted == True,
|
||||
PostReply.posted_at < utcnow() - timedelta(days=7)).all():
|
||||
post_reply.delete_dependencies()
|
||||
db.session.delete(post_reply)
|
||||
|
||||
for post in Post.query.filter(Post.deleted == True,
|
||||
Post.posted_at < utcnow() - timedelta(days=7)).all():
|
||||
post.delete_dependencies()
|
||||
db.session.delete(post)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
# Check for dormant or dead instances
|
||||
instances = Instance.query.filter(Instance.gone_forever == False, Instance.id != 1).all()
|
||||
HEADERS = {'User-Agent': 'PieFed/1.0', 'Accept': 'application/activity+json'}
|
||||
|
@ -284,16 +297,6 @@ def register(app):
|
|||
InstanceRole.role == 'admin').delete()
|
||||
db.session.commit()
|
||||
|
||||
# Delete soft-deleted content after 7 days
|
||||
for post_reply in PostReply.query.filter(PostReply.deleted == True, PostReply.posted_at < utcnow() - timedelta(days=7)).all():
|
||||
db.session.delete(post_reply)
|
||||
|
||||
for post in Post.query.filter(Post.deleted == True, Post.posted_at < utcnow() - timedelta(days=7)).all():
|
||||
post.delete_dependencies()
|
||||
db.session.delete(post)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
@app.cli.command("spaceusage")
|
||||
def spaceusage():
|
||||
with app.app_context():
|
||||
|
|
Loading…
Add table
Reference in a new issue