CLI - add command to clean blacklisted tokens
This commit is contained in:
@ -1,13 +1,9 @@
|
||||
import time
|
||||
|
||||
from fittrackee import db
|
||||
from fittrackee.utils import clean
|
||||
|
||||
|
||||
def clean_tokens(days: int) -> int:
|
||||
limit = int(time.time()) - (days * 86400)
|
||||
sql = """
|
||||
DELETE FROM oauth2_token
|
||||
WHERE oauth2_token.issued_at + oauth2_token.expires_in < %(limit)s;
|
||||
"""
|
||||
result = db.engine.execute(sql, {'limit': limit})
|
||||
return result.rowcount
|
||||
return clean(sql, days)
|
||||
|
@ -7,7 +7,7 @@ from fittrackee.cli.app import app
|
||||
from .clean import clean_tokens
|
||||
|
||||
handler = logging.StreamHandler()
|
||||
logger = logging.getLogger('fittrackee_clean_tokens')
|
||||
logger = logging.getLogger('fittrackee_clean_oauth2_tokens')
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(handler)
|
||||
|
||||
|
Reference in New Issue
Block a user