From a2d5d20372ffb050c8368cff56e9bcb6ee41e21c Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Fri, 5 Feb 2021 23:06:20 +0100 Subject: [PATCH] work --- src/covid19/blueprints/common/common_model.py | 4 ++-- src/covid19/blueprints/europe/europe_model.py | 6 +++++- src/covid19/blueprints/europe/europe_service_update.py | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/covid19/blueprints/common/common_model.py b/src/covid19/blueprints/common/common_model.py index 168acb86..d2aa54c8 100644 --- a/src/covid19/blueprints/common/common_model.py +++ b/src/covid19/blueprints/common/common_model.py @@ -120,14 +120,14 @@ class CommonRegion(db.Model): __tablename__ = 'common_region' type = db.Column('type', db.String(50)) __mapper_args__ = { - 'polymorphic_identity': 'common_date_reported', + 'polymorphic_identity': 'common_region', 'polymorphic_on': type } __table_args__ = ( db.UniqueConstraint('type', 'region', name='unique_common_region_reported'), ) id = db.Column(db.Integer, primary_key=True) - region = db.Column(db.String(255), unique=True) + region = db.Column(db.String(255), nullable=False) @classmethod def remove_all(cls): diff --git a/src/covid19/blueprints/europe/europe_model.py b/src/covid19/blueprints/europe/europe_model.py index e135bae8..e348f28b 100644 --- a/src/covid19/blueprints/europe/europe_model.py +++ b/src/covid19/blueprints/europe/europe_model.py @@ -9,7 +9,11 @@ class EuropeDateReported(CommonDateReported): @classmethod def create_new_object_factory(cls, my_date_rep): - my_datum = date.fromisoformat(my_date_rep) + my_date_parts = my_date_rep.split("/") + my_year = int(my_date_parts[2]) + my_month = int(my_date_parts[1]) + my_day = int(my_date_parts[0]) + my_datum = date(my_year, my_month, my_day) (my_iso_year, week_number, weekday) = my_datum.isocalendar() my_year_week = "" + str(my_iso_year) if week_number < 10: diff --git a/src/covid19/blueprints/europe/europe_service_update.py b/src/covid19/blueprints/europe/europe_service_update.py index cd24b6b1..456e0a50 100644 --- a/src/covid19/blueprints/europe/europe_service_update.py +++ b/src/covid19/blueprints/europe/europe_service_update.py @@ -41,7 +41,7 @@ class EuropeServiceUpdate: my_continent_exp = result_item['continent_exp'] app.logger.info("| " + my_continent_exp + " |") o = EuropeContinent( - continent_exp=my_continent_exp + region=my_continent_exp ) db.session.add(o) db.session.commit() @@ -74,7 +74,7 @@ class EuropeServiceUpdate: result_date_rep = EuropeDataImportTable.get_date_rep() i = 0 for item_date_rep in result_date_rep: - europe_date_reported = EuropeDateReported.find_by( + europe_date_reported = EuropeDateReported.find_by_year_week( year_week=item_date_rep['year_week'] ) result_europe_data_import = EuropeDataImportTable.find_by_date_reported(europe_date_reported) -- GitLab