Пример #1
0
    def handle(self, *args, **options):
        from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype
        from the_tale.forum.prototypes import SubCategoryReadInfoPrototype, ThreadReadInfoPrototype
        from the_tale.post_service.prototypes import MessagePrototype

        PostponedTaskPrototype.remove_old_tasks()

        ThreadReadInfoPrototype.remove_old_infos()
        SubCategoryReadInfoPrototype.remove_old_infos()

        MessagePrototype.remove_old_messages()
Пример #2
0
    def handle(self, *args, **options):
        from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype
        from the_tale.forum.prototypes import SubCategoryReadInfoPrototype, ThreadReadInfoPrototype
        from the_tale.post_service.prototypes import MessagePrototype

        PostponedTaskPrototype.remove_old_tasks()

        ThreadReadInfoPrototype.remove_old_infos()
        SubCategoryReadInfoPrototype.remove_old_infos()

        MessagePrototype.remove_old_messages()
Пример #3
0
    def test_remove_old_tasks(self):
        task = PostponedTaskPrototype.create(FakePostponedInternalTask())
        task.state = POSTPONED_TASK_STATE.PROCESSED
        task.save()

        removed_task = PostponedTaskPrototype.create(FakePostponedInternalTask())
        removed_task.state = POSTPONED_TASK_STATE.ERROR
        removed_task.save()

        PostponedTaskPrototype.remove_old_tasks()

        self.assertEqual(PostponedTask.objects.all().count(), 3)

        with mock.patch('the_tale.common.postponed_tasks.conf.postponed_tasks_settings.TASK_LIVE_TIME', -1):
            PostponedTaskPrototype.remove_old_tasks()

        self.assertEqual(PostponedTask.objects.all().count(), 1)