# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug # Copyright: (c) # Released under the AGPL-3.0 License. from apps.schedule.models import Task, History def auto_clean_schedule_history(): for task in Task.objects.all(): try: record = History.objects.filter(task_id=task.id)[50] History.objects.filter(task_id=task.id, id__lt=record.id).delete() except IndexError: pass