35 lines
801 B
Python
35 lines
801 B
Python
# Create your tasks here
|
|
from __future__ import absolute_import, unicode_literals
|
|
from datetime import timedelta
|
|
from apps.utils.tasks import CustomTask
|
|
from apps.third.models import Tlog
|
|
from celery import shared_task
|
|
from django.utils import timezone
|
|
from apps.third.clients import xxClient, dhClient, spClient
|
|
|
|
|
|
@shared_task(base=CustomTask)
|
|
def clear_tlog():
|
|
"""清除7天前的日志记录
|
|
|
|
清除7天前的日志记录
|
|
"""
|
|
now = timezone.now()
|
|
days7_ago = now - timedelta(days=7)
|
|
Tlog.objects.filter(create_time__lte=days7_ago).delete()
|
|
|
|
|
|
@shared_task(base=CustomTask)
|
|
def get_xx_token():
|
|
xxClient._get_token()
|
|
|
|
|
|
@shared_task(base=CustomTask)
|
|
def get_dh_token():
|
|
dhClient._get_token()
|
|
|
|
|
|
@shared_task(base=CustomTask)
|
|
def get_sp_token():
|
|
spClient._get_token()
|