@celery.task()
def cleanup_database():
    days = timezone.now().date() - timedelta(
        days=settings.STORE_TESTRESULTS_IN_DAYS)

    list(map(lambda launch: launch.testresult_set.all().delete(),
         Launch.objects.filter(finished__lte=days)))
dataset/ETHPy150Open 2gis/badger-api/testreport/tasks.py/cleanup_database/original