Esempio n. 1
0
    def update(self):
        logger.info(f'{self.reg_name}: Update started...')

        self.report_init()
        self.download()

        self.report.update_start = timezone.now()
        self.report.save()

        logger.info(f'{self.reg_name}: save_to_db({self.file_path}) started ...')
        UkCompanyConverter().save_to_db(self.file_path)
        logger.info(f'{self.reg_name}: save_to_db({self.file_path}) finished successfully.')

        self.report.update_finish = timezone.now()
        self.report.update_status = True
        self.report.save()

        self.vacuum_analyze(table_list=['business_register_company', ])

        self.remove_file()
        endpoints_cache_warm_up(endpoints=[
            '/api/company/',
            '/api/company/uk/',
            '/api/company/ukr/',
        ])
        new_total_records = Company.objects.filter(source=Company.GREAT_BRITAIN_REGISTER).count()
        self.update_register_field(settings.UK_COMPANY_REGISTER_LIST, 'total_records', new_total_records)
        logger.info(f'{self.reg_name}: Update total records finished successfully.')

        self.measure_company_changes(Company.GREAT_BRITAIN_REGISTER)
        logger.info(f'{self.reg_name}: Report created successfully.')

        logger.info(f'{self.reg_name}: Update finished successfully.')
Esempio n. 2
0
    def update(self):

        logger.info(f'{self.reg_name}: Update started...')

        self.report_init()
        self.download()

        self.report.update_start = timezone.now()
        self.report.save()

        logger.info(f'{self.reg_name}: process() with {self.file_path} started ...')
        fop = FopConverter()
        fop.LOCAL_FILE_NAME = self.file_name
        sleep(5)
        fop.process()
        logger.info(f'{self.reg_name}: process() with {self.file_path} finished successfully.')

        self.report.update_finish = timezone.now()
        self.report.update_status = True
        self.report.save()

        sleep(5)
        self.vacuum_analyze(table_list=['business_register_fop', ])

        self.remove_file()
        endpoints_cache_warm_up(endpoints=['/api/fop/'])
        new_total_records = Fop.objects.count()
        self.update_register_field(settings.FOP_REGISTER_LIST, 'total_records', new_total_records)
        logger.info(f'{self.reg_name}: Update total records finished successfully.')

        self.measure_changes('business_register', 'Fop')
        logger.info(f'{self.reg_name}: Report created successfully.')

        logger.info(f'{self.reg_name}: Update finished successfully.')
Esempio n. 3
0
    def update(self):
        logger.info(f'{self.reg_name}: Update started...')

        self.report_init()

        self.report.update_start = timezone.now()
        self.report.save()

        logger.info(f'{self.reg_name}: process() started ...')
        converter = PepConverterFromDB()
        converter.process()
        self.report.update_finish = timezone.now()
        self.report.save()

        self.vacuum_analyze(table_list=[
            'business_register_pep',
        ])
        endpoints_cache_warm_up(endpoints=['/api/pep/'])
        self.report.update_status = True
        peps_total_records = Pep.objects.all().count()
        if peps_total_records != converter.peps_total_records_from_source:
            self.report.update_status = False
            self.report.update_message = (
                f'Total records of PEP objects from source is '
                f'{converter.peps_total_records_from_source} '
                f'but in our DB it is {peps_total_records}. \n')
            self.report.save()
        peps_links_total_records = RelatedPersonsLink.objects.all().count()
        if peps_links_total_records != converter.peps_links_total_records_from_source:
            self.report.update_status = False
            self.report.update_message += (
                f'Total records of RelatedPersonsLink from source is '
                f'{converter.peps_links_total_records_from_source} '
                f'but in our DB it is {peps_links_total_records}. \n')
        peps_companies_total_records = CompanyLinkWithPep.objects.all().count()
        if peps_companies_total_records != converter.peps_companies_total_records_from_source:
            self.report.update_status = False
            self.report.update_message += (
                f'Total records of CompanyLinkWithPep from source is '
                f'{converter.peps_companies_total_records_from_source} '
                f'but in our DB it is {peps_companies_total_records}')
            self.report.save()

        self.update_register_field(settings.PEP_REGISTER_LIST, 'total_records',
                                   peps_total_records)
        self.report.save()

        self.report.invalid_data = converter.invalid_data_counter
        self.measure_changes('business_register', 'Pep')
        self.report.save()
        logger.info(f'{self.reg_name}: Report created successfully.')

        if self.report.update_status:
            logger.info(f'{self.reg_name}: Update finished unsuccessfully')
        else:
            logger.info(
                f'{self.reg_name}: Update finished unsuccessfully. See update_message'
            )
Esempio n. 4
0
    def update(self):

        logger.info(f'{self.reg_name}: Update started...')

        self.report_init()
        self.download()

        self.report.update_start = timezone.now()
        self.report.save()

        logger.info(
            f'{self.reg_name}: process() with {self.file_path} started ...')
        ukr_company = UkrCompanyConverter()
        ukr_company.LOCAL_FILE_NAME = self.file_name
        sleep(5)
        ukr_company.process()
        logger.info(
            f'{self.reg_name}: process() with {self.file_path} finished successfully.'
        )

        self.report.update_finish = timezone.now()
        self.report.update_status = True
        self.report.save()

        sleep(5)
        self.vacuum_analyze(table_list=[
            'business_register_company',
        ])

        self.remove_file()
        endpoints_cache_warm_up(endpoints=[
            '/api/company/',
            '/api/company/uk/',
            '/api/company/ukr/',
        ])
        new_total_records = Company.objects.filter(
            source=Company.UKRAINE_REGISTER).count()
        self.update_register_field(settings.UKR_COMPANY_REGISTER_LIST,
                                   'total_records', new_total_records)
        logger.info(
            f'{self.reg_name}: Update total records finished successfully.')

        self.measure_company_changes(Company.UKRAINE_REGISTER)
        logger.info(f'{self.reg_name}: Report created successfully.')

        logger.info(f'{self.reg_name}: Update finished successfully.')