コード例 #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
ファイル: portal_clean.py プロジェクト: lshestov/the-tale
    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_messages(self):
        message_1 = MessagePrototype.create(handler=TestHandler())
        message_1._model.state = MESSAGE_STATE.PROCESSED
        message_1.save()

        message_2 = MessagePrototype.create(handler=TestHandler())
        message_2._model.created_at -= datetime.timedelta(seconds=post_service_settings.MESSAGE_LIVE_TIME)
        message_2._model.state = MESSAGE_STATE.PROCESSED
        message_2.save()

        message_3 = MessagePrototype.create(handler=TestHandler())
        message_3._model.created_at -= datetime.timedelta(seconds=post_service_settings.MESSAGE_LIVE_TIME)
        message_3.save()

        MessagePrototype.remove_old_messages()

        self.assertEqual(MessagePrototype._db_count(), 2)
        self.assertEqual(MessagePrototype._db_get_object(0).id, message_1.id)
        self.assertEqual(MessagePrototype._db_get_object(1).id, message_3.id)
コード例 #4
0
ファイル: test_prototype.py プロジェクト: pavetok/the-tale
    def test_remove_old_messages(self):
        message_1 = MessagePrototype.create(handler=TestHandler())
        message_1._model.state = MESSAGE_STATE.PROCESSED
        message_1.save()

        message_2 = MessagePrototype.create(handler=TestHandler())
        message_2._model.created_at -= datetime.timedelta(
            seconds=post_service_settings.MESSAGE_LIVE_TIME)
        message_2._model.state = MESSAGE_STATE.PROCESSED
        message_2.save()

        message_3 = MessagePrototype.create(handler=TestHandler())
        message_3._model.created_at -= datetime.timedelta(
            seconds=post_service_settings.MESSAGE_LIVE_TIME)
        message_3.save()

        MessagePrototype.remove_old_messages()

        self.assertEqual(MessagePrototype._db_count(), 2)
        self.assertEqual(MessagePrototype._db_get_object(0).id, message_1.id)
        self.assertEqual(MessagePrototype._db_get_object(1).id, message_3.id)