From c2c67ea2f6a38a270d766eb10be33c6ac38f52b5 Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Mon, 8 Feb 2021 10:04:02 +0100 Subject: [PATCH] work --- BACKLOG.md | 12 ++++++------ src/covid19/blueprints/europe/europe_model_import.py | 10 +++++----- .../blueprints/europe/europe_service_import.py | 6 +++--- .../blueprints/europe/europe_service_update.py | 12 ++++++------ src/covid19/blueprints/europe/europe_views.py | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/BACKLOG.md b/BACKLOG.md index e2f7c8aa..664c0fdb 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -106,8 +106,8 @@ ### 0.0.15 Release * Issue #39 SQLalchemy instead of SQL: AllModelClasses.remove_all() -* Issue #40 SQLalchemy instead of SQL: EuropeDataImport.get_date_rep() -* Issue #41 SQLalchemy instead of SQL: EuropeDataImport.get_countries_of_continent() +* Issue #40 SQLalchemy instead of SQL: EuropeImport.get_date_rep() +* Issue #41 SQLalchemy instead of SQL: EuropeImport.get_countries_of_continent() * Issue #42 SQLalchemy instead of SQL: WhoGlobalDataImportTable.get_new_dates_as_array() * Issue #71 add python modules to requirements.txt for User Login, Authentication and Autorisation * Issue #72 add python modules to requirements.txt for Ajax and other JS Features @@ -144,10 +144,10 @@ * Issue #104 implement VaccinationsServiceUpdate.update_star_schema_incremental * Issue #105 implement VaccinationsServiceUpdate.update_star_schema_initial * Issue #106 add Tasks and URLs for starting Tasks to vaccination_views -* Issue #107 SQLalchemy instead of SQL in: EuropeDataImport.get_countries_of_continent -* Issue #108 change to ORM ClassHierarchy in: EuropeDataImport.get_countries_of_continent -* Issue #109 SQLalchemy instead of SQL in: EuropeDataImport.get_date_rep -* Issue #110 SQLalchemy instead of SQL in: EuropeDataImport.get_continent +* Issue #107 SQLalchemy instead of SQL in: EuropeImport.get_countries_of_continent +* Issue #108 change to ORM ClassHierarchy in: EuropeImport.get_countries_of_continent +* Issue #109 SQLalchemy instead of SQL in: EuropeImport.get_date_rep +* Issue #110 SQLalchemy instead of SQL in: EuropeImport.get_continent * Issue #111 refactor to new method scheme itroduced 07.02.2021 * Issue #112 implement EuropeService.run_update_dimension_tables_only * Issue #113 implement EuropeService.run_update_fact_table_incremental_only diff --git a/src/covid19/blueprints/europe/europe_model_import.py b/src/covid19/blueprints/europe/europe_model_import.py index 3c4e79a8..cc79b0b6 100644 --- a/src/covid19/blueprints/europe/europe_model_import.py +++ b/src/covid19/blueprints/europe/europe_model_import.py @@ -1,7 +1,7 @@ from database import db, ITEMS_PER_PAGE -class EuropeDataImport(db.Model): +class EuropeImport(db.Model): __tablename__ = 'europe_import' id = db.Column(db.Integer, primary_key=True) @@ -44,13 +44,13 @@ class EuropeDataImport(db.Model): @classmethod def get_date_rep(cls): - # TODO: #109 SQLalchemy instead of SQL in: EuropeDataImport.get_date_rep + # TODO: #109 SQLalchemy instead of SQL in: EuropeImport.get_date_rep sql = "select distinct date_rep, year_week from europe_import order by year_week desc" return db.session.execute(sql).fetchall() @classmethod def get_continent(cls): - # TODO: #110 SQLalchemy instead of SQL in: EuropeDataImport.get_continent + # TODO: #110 SQLalchemy instead of SQL in: EuropeImport.get_continent sql = "select distinct continent_exp from europe_import order by continent_exp asc" return db.session.execute(sql).fetchall() @@ -59,8 +59,8 @@ class EuropeDataImport(db.Model): my_continent_exp = my_continent.region my_params = {} my_params['my_continent_param'] = my_continent_exp - #TODO: #107 SQLalchemy instead of SQL in: EuropeDataImport.get_countries_of_continent - #TODO: #108 BUG: change to ORM ClassHierarchy in: EuropeDataImport.get_countries_of_continent + #TODO: #107 SQLalchemy instead of SQL in: EuropeImport.get_countries_of_continent + #TODO: #108 BUG: change to ORM ClassHierarchy in: EuropeImport.get_countries_of_continent sql = """ select distinct countries_and_territories, diff --git a/src/covid19/blueprints/europe/europe_service_import.py b/src/covid19/blueprints/europe/europe_service_import.py index 2ef7b7f6..af4f0b31 100644 --- a/src/covid19/blueprints/europe/europe_service_import.py +++ b/src/covid19/blueprints/europe/europe_service_import.py @@ -3,7 +3,7 @@ import csv import psycopg2 from database import db, app -from covid19.blueprints.europe.europe_model_import import EuropeDataImport +from covid19.blueprints.europe.europe_model_import import EuropeImport from covid19.blueprints.europe.europe_service_config import EuropeServiceDownloadConfig @@ -26,11 +26,11 @@ class EuropeServiceImport: app.logger.info("------------------------------------------------------------") k = 0 try: - EuropeDataImport.remove_all() + EuropeImport.remove_all() with open(src_cvsfile_name, newline='') as csv_file: file_reader = csv.DictReader(csv_file, delimiter=',', quotechar='"') for row in file_reader: - o = EuropeDataImport( + o = EuropeImport( date_rep=row['dateRep'], year_week=row['year_week'], cases_weekly=row['cases_weekly'], diff --git a/src/covid19/blueprints/europe/europe_service_update.py b/src/covid19/blueprints/europe/europe_service_update.py index 4e509685..7674e891 100644 --- a/src/covid19/blueprints/europe/europe_service_update.py +++ b/src/covid19/blueprints/europe/europe_service_update.py @@ -1,6 +1,6 @@ from database import db, app from covid19.blueprints.europe.europe_service_config import EuropeServiceDownloadConfig -from covid19.blueprints.europe.europe_model_import import EuropeDataImport +from covid19.blueprints.europe.europe_model_import import EuropeImport from covid19.blueprints.europe.europe_model import EuropeDateReported, EuropeContinent, EuropeCountry, EuropeData @@ -18,7 +18,7 @@ class EuropeServiceUpdate: def __update_date_reported(self): app.logger.info(" __update_date_reported [begin]") app.logger.info("------------------------------------------------------------") - result_date_rep = EuropeDataImport.get_date_rep() + result_date_rep = EuropeImport.get_date_rep() k = 0 for result_item in result_date_rep: k += 1 @@ -37,7 +37,7 @@ class EuropeServiceUpdate: def __update_continent(self): app.logger.info(" __update_continent [begin]") app.logger.info("------------------------------------------------------------") - result_continent = EuropeDataImport.get_continent() + result_continent = EuropeImport.get_continent() for result_item in result_continent: my_continent_exp = result_item['continent_exp'] o = EuropeContinent( @@ -55,7 +55,7 @@ class EuropeServiceUpdate: app.logger.info("------------------------------------------------------------") all_continents = EuropeContinent.get_all() for my_continent in all_continents: - result_countries_of_continent = EuropeDataImport.get_countries_of_continent(my_continent) + result_countries_of_continent = EuropeImport.get_countries_of_continent(my_continent) for c in result_countries_of_continent: o = EuropeCountry( countries_and_territories=c['countries_and_territories'], @@ -73,7 +73,7 @@ class EuropeServiceUpdate: def __update_data_initial(self): app.logger.info(" __update_data_initial [begin]") app.logger.info("------------------------------------------------------------") - result_date_rep = EuropeDataImport.get_date_rep() + result_date_rep = EuropeImport.get_date_rep() i = 0 for item_date_rep in result_date_rep: europe_date_reported = EuropeDateReported.find_by_date_reported( @@ -82,7 +82,7 @@ class EuropeServiceUpdate: if europe_date_reported is None: o = EuropeDateReported.create_new_object_factory(item_date_rep['date_rep']) europe_date_reported = o - result_europe_data_import = EuropeDataImport.find_by_date_reported(europe_date_reported) + result_europe_data_import = EuropeImport.find_by_date_reported(europe_date_reported) for item_europe_data_import in result_europe_data_import: my_a = item_europe_data_import.countries_and_territories my_b = item_europe_data_import.geo_id diff --git a/src/covid19/blueprints/europe/europe_views.py b/src/covid19/blueprints/europe/europe_views.py index baa194d5..00d3c6db 100644 --- a/src/covid19/blueprints/europe/europe_views.py +++ b/src/covid19/blueprints/europe/europe_views.py @@ -6,7 +6,7 @@ from database import app from covid19.services import europe_service from covid19.workers import celery -from covid19.blueprints.europe.europe_model_import import EuropeDataImport +from covid19.blueprints.europe.europe_model_import import EuropeImport from covid19.blueprints.europe.europe_model import EuropeDateReported, EuropeContinent, EuropeCountry, EuropeData from covid19.blueprints.common.common_model_transient import ApplicationPage @@ -85,7 +85,7 @@ def europe_update_data_short(): @app_europe.route('/imported') def url_europe_data_imported(page=1): page_info = ApplicationPage('Europe', "Last Import") - page_data = EuropeDataImport.get_all_as_page(page) + page_data = EuropeImport.get_all_as_page(page) return render_template( 'europe/europe_imported.html', page_data=page_data, -- GitLab