From ad62f2348146c61e678268f7f0d9cee5c193b11e Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Mon, 24 May 2021 12:42:26 +0200 Subject: [PATCH] Refactoring: vaccination --- docs/BACKLOG.md | 4 ++-- src/flask_covid19/__init__.py | 2 +- src/flask_covid19/blueprints/app_all/all_config.py | 4 ++-- .../data_vaccination/vaccination_model_import.py | 4 ++-- .../data_vaccination/vaccination_service_import.py | 6 +++--- .../data_vaccination/vaccination_service_update.py | 14 +++++++------- .../data_vaccination/vaccination_views.py | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/BACKLOG.md b/docs/BACKLOG.md index e11dd920..6e94f1eb 100644 --- a/docs/BACKLOG.md +++ b/docs/BACKLOG.md @@ -125,7 +125,7 @@ ### 0.0.15 Release * ------------------------------------- -* Fixed #88 rename RkiVaccinationImport to RkiVaccinationImport +* Fixed #88 rename VaccinationImport to VaccinationImport * Fixed #89 change tablename from vaccination_germany_timeline_import to vaccination_import * Fixed #86 rename RkiVaccinationData to RkiVaccinationData * Fixed #162 rename table vaccination_germany_timeline into vaccination_data @@ -431,7 +431,7 @@ ### 0.0.35 Release * ------------------------------------- -* Issue #195 RkiVaccinationImport.get_daterep_missing_in_vaccination_data(): native SQL to SQLalechemy Query +* Issue #195 VaccinationImport.get_daterep_missing_in_vaccination_data(): native SQL to SQLalechemy Query * ------------------------------------- * Issue #207 remove deprecated: database.port * Issue #208 remove deprecated: database.run_run_with_debug diff --git a/src/flask_covid19/__init__.py b/src/flask_covid19/__init__.py index 1532957f..87bffe41 100644 --- a/src/flask_covid19/__init__.py +++ b/src/flask_covid19/__init__.py @@ -3,7 +3,7 @@ from database import app from flask_covid19.blueprints.data_ecdc.ecdc_model_import import EcdcImport from flask_covid19.blueprints.data_who.who_service_import import WhoImport -from flask_covid19.blueprints.data_vaccination.vaccination_model_import import RkiVaccinationImport +from flask_covid19.blueprints.data_vaccination.vaccination_model_import import VaccinationImport from flask_covid19.blueprints.data_owid.owid_model_import import OwidImport from flask_covid19.blueprints.data_rki_cases.rki_model_import import RkiImport from flask_covid19.blueprints.data_divi.divi_model_import import DiviImport diff --git a/src/flask_covid19/blueprints/app_all/all_config.py b/src/flask_covid19/blueprints/app_all/all_config.py index 23b9b00e..007fb32a 100644 --- a/src/flask_covid19/blueprints/app_all/all_config.py +++ b/src/flask_covid19/blueprints/app_all/all_config.py @@ -3,7 +3,7 @@ import os from database import root_dir from flask_covid19.blueprints.data_ecdc.ecdc_model_import import EcdcImport from flask_covid19.blueprints.data_who.who_model_import import WhoImport -from flask_covid19.blueprints.data_vaccination.vaccination_model_import import RkiVaccinationImport +from flask_covid19.blueprints.data_vaccination.vaccination_model_import import VaccinationImport from flask_covid19.blueprints.data_owid.owid_model_import import OwidImport from flask_covid19.blueprints.data_rki_cases.rki_model_import import RkiImport from flask_covid19.blueprints.data_divi.divi_model_import import DiviImport @@ -56,7 +56,7 @@ class BlueprintConfig: category='RKI', cvsfile_subpath='rki_vaccination', sub_category='Vaccination', - tablename=RkiVaccinationImport.__tablename__, + tablename=VaccinationImport.__tablename__, cvsfile_name="RKI_Vaccination.tsv", cvsfile_backup_name='RKI_Vaccination_backup.tsv', url_src="https://impfdashboard.de/static/data/germany_vaccinations_timeseries_v2.tsv", diff --git a/src/flask_covid19/blueprints/data_vaccination/vaccination_model_import.py b/src/flask_covid19/blueprints/data_vaccination/vaccination_model_import.py index df4aced3..feab740e 100644 --- a/src/flask_covid19/blueprints/data_vaccination/vaccination_model_import.py +++ b/src/flask_covid19/blueprints/data_vaccination/vaccination_model_import.py @@ -1,7 +1,7 @@ from database import db, ITEMS_PER_PAGE -class RkiVaccinationImport(db.Model): +class VaccinationImport(db.Model): __tablename__ = 'vaccination_import' id = db.Column(db.Integer, primary_key=True) @@ -87,7 +87,7 @@ class RkiVaccinationImport(db.Model): resultarray.append(o) return resultarray - # TODO #195 RkiVaccinationImport.get_daterep_missing_in_vaccination_data(): native SQL to SQLalechemy Query + # TODO #195 VaccinationImport.get_daterep_missing_in_vaccination_data(): native SQL to SQLalechemy Query @classmethod def get_daterep_missing_in_vaccination_data(cls): sql_query = """ diff --git a/src/flask_covid19/blueprints/data_vaccination/vaccination_service_import.py b/src/flask_covid19/blueprints/data_vaccination/vaccination_service_import.py index 577ccd0e..02f8fc3c 100644 --- a/src/flask_covid19/blueprints/data_vaccination/vaccination_service_import.py +++ b/src/flask_covid19/blueprints/data_vaccination/vaccination_service_import.py @@ -6,7 +6,7 @@ from database import db, app from flask_covid19.blueprints.app_all.all_config import BlueprintConfig from flask_covid19.blueprints.data_vaccination.vaccination_model import RkiVaccinationDateReported -from flask_covid19.blueprints.data_vaccination.vaccination_model_import import RkiVaccinationImport, RkiVaccinationFlat +from flask_covid19.blueprints.data_vaccination.vaccination_model_import import VaccinationImport, RkiVaccinationFlat class RkiVaccinationServiceImport: @@ -32,7 +32,7 @@ class RkiVaccinationServiceImport: app.logger.info(" import into TABLE: "+self.cfg.tablename+" from "+self.cfg.cvsfile_path) app.logger.info("------------------------------------------------------------") try: - RkiVaccinationImport.remove_all() + VaccinationImport.remove_all() RkiVaccinationFlat.remove_all() k = 0 with open(src_cvsfile_name, newline='\n') as csv_file: @@ -40,7 +40,7 @@ class RkiVaccinationServiceImport: for row in file_reader: date_reported = row['date'] d = RkiVaccinationDateReported.create_new_object_factory(my_date_rep=date_reported) - o = RkiVaccinationImport( + o = VaccinationImport( dosen_kumulativ=self.__int(row['dosen_kumulativ']), dosen_differenz_zum_vortag=self.__int(row['dosen_differenz_zum_vortag']), dosen_biontech_kumulativ=self.__int(row['dosen_biontech_kumulativ']), diff --git a/src/flask_covid19/blueprints/data_vaccination/vaccination_service_update.py b/src/flask_covid19/blueprints/data_vaccination/vaccination_service_update.py index 9baa8ada..cad987cc 100644 --- a/src/flask_covid19/blueprints/data_vaccination/vaccination_service_update.py +++ b/src/flask_covid19/blueprints/data_vaccination/vaccination_service_update.py @@ -1,6 +1,6 @@ from database import db, app from flask_covid19.blueprints.app_all.all_config import BlueprintConfig -from flask_covid19.blueprints.data_vaccination.vaccination_model_import import RkiVaccinationImport +from flask_covid19.blueprints.data_vaccination.vaccination_model_import import VaccinationImport from flask_covid19.blueprints.data_vaccination.vaccination_model import RkiVaccinationDateReported from flask_covid19.blueprints.data_vaccination.vaccination_model import RkiVaccinationData @@ -22,7 +22,7 @@ class RkiVaccinationServiceUpdateFull(RkiVaccinationServiceUpdateBase): app.logger.info(" RkiVaccinationServiceUpdateFull.__full_update_date_reported [begin]") app.logger.info("------------------------------------------------------------") RkiVaccinationDateReported.remove_all() - date_reported_list = RkiVaccinationImport.get_date_reported_as_array() + date_reported_list = VaccinationImport.get_date_reported_as_array() i = 0 for one_date_reported in date_reported_list: i += 1 @@ -39,13 +39,13 @@ class RkiVaccinationServiceUpdateFull(RkiVaccinationServiceUpdateBase): app.logger.info(" __update_data_initial [begin]") app.logger.info("------------------------------------------------------------") RkiVaccinationData.remove_all() - result_date_rep = RkiVaccinationImport.get_date_rep() + result_date_rep = VaccinationImport.get_date_rep() i = 0 for item_date_rep, in result_date_rep: d = RkiVaccinationDateReported.get_by_datum( d_datum=item_date_rep ) - for item_import in RkiVaccinationImport.find_by_datum(d.date_reported_import_str): + for item_import in VaccinationImport.find_by_datum(d.date_reported_import_str): o = RkiVaccinationData( date_reported=d, dosen_kumulativ=item_import.dosen_kumulativ, @@ -104,7 +104,7 @@ class RkiVaccinationServiceUpdate(RkiVaccinationServiceUpdateBase): app.logger.info(" __update_date_reported [begin]") app.logger.info("------------------------------------------------------------") RkiVaccinationDateReported.remove_all() - date_reported_list = RkiVaccinationImport.get_date_reported_as_array() + date_reported_list = VaccinationImport.get_date_reported_as_array() i = 0 for one_date_reported in date_reported_list: i += 1 @@ -120,11 +120,11 @@ class RkiVaccinationServiceUpdate(RkiVaccinationServiceUpdateBase): def __update_fact_table(self): app.logger.info(" __update_fact_table_incremental Vaccination [begin]") app.logger.info("------------------------------------------------------------") - result_date_rep = RkiVaccinationImport.get_daterep_missing_in_vaccination_data() + result_date_rep = VaccinationImport.get_daterep_missing_in_vaccination_data() i = 0 for item_date_rep in result_date_rep: date_reported = RkiVaccinationDateReported.get_by_date_reported(item_date_rep) - for item_data_import in RkiVaccinationImport.find_by_datum(item_date_rep): + for item_data_import in VaccinationImport.find_by_datum(item_date_rep): o = RkiVaccinationData( date_reported=date_reported, dosen_kumulativ=item_data_import.dosen_kumulativ, diff --git a/src/flask_covid19/blueprints/data_vaccination/vaccination_views.py b/src/flask_covid19/blueprints/data_vaccination/vaccination_views.py index 731ec457..baff3a08 100644 --- a/src/flask_covid19/blueprints/data_vaccination/vaccination_views.py +++ b/src/flask_covid19/blueprints/data_vaccination/vaccination_views.py @@ -8,13 +8,13 @@ from flask_covid19.blueprints.app_web.web_services import vaccination_service from flask_covid19.blueprints.data_vaccination.vaccination_model import RkiVaccinationData from flask_covid19.blueprints.data_vaccination.vaccination_model import RkiVaccinationDateReported -from flask_covid19.blueprints.data_vaccination.vaccination_model_import import RkiVaccinationImport, RkiVaccinationFlat +from flask_covid19.blueprints.data_vaccination.vaccination_model_import import VaccinationImport, RkiVaccinationFlat from flask_covid19.blueprints.app_web.web_model_transient import WebPageContent app_vaccination = Blueprint('vaccination', __name__, template_folder='templates', url_prefix='/vaccination') -admin.add_view(ModelView(RkiVaccinationImport, db.session, category="Vaccination")) +admin.add_view(ModelView(VaccinationImport, db.session, category="Vaccination")) admin.add_view(ModelView(RkiVaccinationFlat, db.session, category="Vaccination")) admin.add_view(ModelView(RkiVaccinationDateReported, db.session, category="Vaccination")) admin.add_view(ModelView(RkiVaccinationData, db.session, category="Vaccination")) @@ -44,7 +44,7 @@ def url_vaccination_tasks(): @app_vaccination.route('/imported') def url_vaccination_imported(page=1): page_info = WebPageContent('Vaccination', "Data: Germany Timeline imported") - page_data = RkiVaccinationImport.get_all_as_page(page) + page_data = VaccinationImport.get_all_as_page(page) return render_template( 'rki_vaccination/imported/rki_vaccination_imported.html', page_data=page_data, -- GitLab