Esempio n. 1
0
    def testWrite_ScraperSuccessWithDate(self):
        store_scraper_success(ScraperSuccessModel(date=_TODAY), "01001001")

        query = SessionFactory.for_schema_base(JailsBase).query(ScraperSuccessTable)
        result = one(query.all())

        self.assertEqual(result.jid, _JID)
        self.assertEqual(result.date, _TODAY)
    def testWrite_ScraperSuccessWithDate(self):
        store_scraper_success(ScraperSuccessModel(date=_TODAY), "01001001")

        with SessionFactory.using_database(self.database_key,
                                           autocommit=False) as session:
            query = session.query(ScraperSuccessTable)
            result = one(query.all())

        self.assertEqual(result.jid, _JID)
        self.assertEqual(result.date, _TODAY)
Esempio n. 3
0
def update_phase(session: ScrapeSession, phase: scrape_phase.ScrapePhase):
    """Updates the phase of the session to the given phase."""
    #  TODO(#1665): remove once dangling PERSIST session investigation
    #   is complete.
    logging.info("Updating phase from %s to %s", session.phase, phase)

    previous_phase = session.phase

    session.phase = phase
    retry_grpc(NUM_GRPC_RETRIES, ds().put, session.to_entity())

    if previous_phase == scrape_phase.ScrapePhase.RELEASE and \
       phase == scrape_phase.ScrapePhase.DONE:
        jid = regions.get_region(session.region).jurisdiction_id
        store_scraper_success(ScraperSuccess(), jid)