You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
613 B
28 lines
613 B
10 years ago
|
# -*- encoding: utf-8 -*-
|
||
|
|
||
10 years ago
|
import logging
|
||
|
log = logging.getLogger("isso")
|
||
|
|
||
|
from isso.controllers import threads, comments
|
||
10 years ago
|
|
||
|
from . import Cron
|
||
|
|
||
|
|
||
|
class Purge(Cron):
|
||
|
|
||
|
def __init__(self, db, after):
|
||
|
super(Purge, self).__init__(hours=1)
|
||
|
self.after = after
|
||
|
|
||
10 years ago
|
self.threads = threads.Controller(db)
|
||
|
self.comments = comments.Controller(db)
|
||
|
|
||
10 years ago
|
def run(self, data):
|
||
10 years ago
|
rows = self.comments.prune(self.after)
|
||
|
if rows:
|
||
|
log.info("removed %s comment(s)", rows)
|
||
|
|
||
|
rows = self.threads.prune()
|
||
|
if rows:
|
||
|
log.info("removed %s thread(s)", rows)
|