blob: 3e056d145e4848f4e0fe33a747ed1f84ca3e5f86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/env python3
from srht.config import cfg, cfgi, load_config
load_config("git")
from srht.database import DbSession
db = DbSession(cfg("sr.ht", "connection-string"))
from gitsrht.types import Repository, RepoVisibility
db.init()
from datetime import datetime, timedelta
def cleanup_autocreated():
due = datetime.utcnow() - timedelta(minutes=20)
repos = (Repository.query
.filter(Repository.visibility == RepoVisibility.autocreated)
.filter(Repository.created < due)).all()
(db.session.delete(r) for r in repos)
db.session.commit()
cleanup_autocreated()
|