Ejemplo n.º 1
0
    def test_query_getting_overdue_scheduled_content(self):
        with self.app.app_context():
            self.app.data.insert(ARCHIVE,
                                 [{
                                     'publish_schedule': get_expiry_date(-10),
                                     'state': 'published'
                                 }])
            self.app.data.insert(ARCHIVE,
                                 [{
                                     'publish_schedule': get_expiry_date(-10),
                                     'state': 'scheduled'
                                 }])
            self.app.data.insert(ARCHIVE,
                                 [{
                                     'publish_schedule': get_expiry_date(0),
                                     'state': 'spiked'
                                 }])
            self.app.data.insert(ARCHIVE,
                                 [{
                                     'publish_schedule': get_expiry_date(10),
                                     'state': 'scheduled'
                                 }])
            self.app.data.insert(ARCHIVE, [{
                'unique_id': 97,
                'state': 'spiked'
            }])

            now = date_to_str(utcnow())
            overdueItems = get_overdue_scheduled_items(now, 'archive')
            self.assertEquals(1, overdueItems.count())
Ejemplo n.º 2
0
    def update_overdue_scheduled(self):
        """
        Updates the overdue scheduled content on published collection.
        """

        logger.info('Updating overdue scheduled content')

        if is_task_running("publish", "update_overdue_scheduled",
                           UPDATE_OVERDUE_SCHEDULED_DEFAULT):
            return

        try:
            now = date_to_str(utcnow())
            items = get_overdue_scheduled_items(now, 'published')

            for item in items:
                logger.info(
                    'updating overdue scheduled article with id {} and headline {} -- expired on: {} now: {}'
                    .format(item[config.ID_FIELD], item['headline'],
                            item['publish_schedule'], now))

                superdesk.get_resource_service('published').\
                    update_published_items(item['item_id'], ITEM_STATE, CONTENT_STATE.PUBLISHED)
        finally:
            mark_task_as_not_running("publish", "update_overdue_scheduled")
Ejemplo n.º 3
0
    def update_overdue_scheduled(self):
        """
        Updates the overdue scheduled content on published collection.
        """

        logger.info("Updating overdue scheduled content")

        if is_task_running("publish", "update_overdue_scheduled", UPDATE_OVERDUE_SCHEDULED_DEFAULT):
            return

        try:
            now = date_to_str(utcnow())
            items = get_overdue_scheduled_items(now, "published")

            for item in items:
                logger.info(
                    "updating overdue scheduled article with id {} and headline {} -- expired on: {} now: {}".format(
                        item[config.ID_FIELD], item["headline"], item["publish_schedule"], now
                    )
                )

                superdesk.get_resource_service("published").update_published_items(
                    item["item_id"], ITEM_STATE, CONTENT_STATE.PUBLISHED
                )
        finally:
            mark_task_as_not_running("publish", "update_overdue_scheduled")
Ejemplo n.º 4
0
    def test_query_getting_overdue_scheduled_content(self):
        self.app.data.insert(ARCHIVE, [{'publish_schedule': get_expiry_date(-10), 'state': 'published'}])
        self.app.data.insert(ARCHIVE, [{'publish_schedule': get_expiry_date(-10), 'state': 'scheduled'}])
        self.app.data.insert(ARCHIVE, [{'publish_schedule': get_expiry_date(0), 'state': 'spiked'}])
        self.app.data.insert(ARCHIVE, [{'publish_schedule': get_expiry_date(10), 'state': 'scheduled'}])
        self.app.data.insert(ARCHIVE, [{'unique_id': 97, 'state': 'spiked'}])

        now = date_to_str(utcnow())
        overdueItems = get_overdue_scheduled_items(now, 'archive')
        self.assertEquals(1, overdueItems.count())
Ejemplo n.º 5
0
    def test_query_getting_overdue_scheduled_content(self):
        with self.app.app_context():
            self.app.data.insert(ARCHIVE, [{"publish_schedule": get_expiry_date(-10), "state": "published"}])
            self.app.data.insert(ARCHIVE, [{"publish_schedule": get_expiry_date(-10), "state": "scheduled"}])
            self.app.data.insert(ARCHIVE, [{"publish_schedule": get_expiry_date(0), "state": "spiked"}])
            self.app.data.insert(ARCHIVE, [{"publish_schedule": get_expiry_date(10), "state": "scheduled"}])
            self.app.data.insert(ARCHIVE, [{"unique_id": 97, "state": "spiked"}])

            now = date_to_str(utcnow())
            overdueItems = get_overdue_scheduled_items(now, "archive")
            self.assertEquals(1, overdueItems.count())