mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Added task to clean-up old API access logs
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from django.conf import settings
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from celery.decorators import task
|
from celery.decorators import task
|
||||||
@@ -8,5 +9,16 @@ def clear_stale_cache(cache_extension=0):
|
|||||||
log = clear_stale_cache.get_logger()
|
log = clear_stale_cache.get_logger()
|
||||||
|
|
||||||
time = datetime.utcnow() - timedelta(seconds=cache_extension)
|
time = datetime.utcnow() - timedelta(seconds=cache_extension)
|
||||||
objs = CachedDocument.objects.filter(cached_until__lt=datetime.utcnow()).delete()
|
objs = CachedDocument.objects.filter(cached_until__lt=time)
|
||||||
self.log.info('Removed %s stale cache documents' % objs.count())
|
log.info('Removing %s stale cache documents' % objs.count())
|
||||||
|
objs.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@task(ignore_result=True)
|
||||||
|
def clear_old_logs():
|
||||||
|
log = clear_old_logs.get_logger()
|
||||||
|
|
||||||
|
time = datetime.utcnow() - timedelta(day=settings.EVE_PROXY_KEEP_LOGS)
|
||||||
|
objs = ApiAccessLog.objects.filter(time_access__lt=time)
|
||||||
|
log.info('Removing %s old access logs' % objs.count())
|
||||||
|
objs.delete()
|
||||||
|
|||||||
@@ -155,6 +155,11 @@ FULL_API_CHARACTER_ID = 246102445
|
|||||||
|
|
||||||
BANNED_EMAIL_DOMAINS = ['att.net']
|
BANNED_EMAIL_DOMAINS = ['att.net']
|
||||||
|
|
||||||
|
|
||||||
|
## Eve Proxy settings
|
||||||
|
|
||||||
|
EVE_PROXY_KEEP_LOGS = 30
|
||||||
|
|
||||||
# try and import local settings
|
# try and import local settings
|
||||||
try:
|
try:
|
||||||
from settingslocal import *
|
from settingslocal import *
|
||||||
@@ -176,6 +181,9 @@ CELERYBEAT_SCHEDULE = {
|
|||||||
"task": "eve_api.tasks.alliance.import_alliance_details",
|
"task": "eve_api.tasks.alliance.import_alliance_details",
|
||||||
"schedule": timedelta(hours=6),
|
"schedule": timedelta(hours=6),
|
||||||
},
|
},
|
||||||
|
"api-log-clear": {
|
||||||
|
"task": "eve_proxy.tasks.clear_old_logs"
|
||||||
|
"schedule": timedelta(days=1)
|
||||||
}
|
}
|
||||||
|
|
||||||
CELERY_SEND_TASK_ERROR_EMAILS = True
|
CELERY_SEND_TASK_ERROR_EMAILS = True
|
||||||
|
|||||||
Reference in New Issue
Block a user