From 63dc83566773f6f2f4c6f05e82c7812769364c02 Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Mon, 8 Feb 2021 20:54:16 +0100 Subject: [PATCH] start DEV 0.0.15 --- src/covid19/blueprints/europe/europe_model.py | 7 +++++-- src/covid19/blueprints/rki/rki_model.py | 7 +++++-- src/covid19/blueprints/vaccination/vaccination_model.py | 9 ++++++--- .../blueprints/vaccination/vaccination_service_update.py | 4 ++-- src/covid19/blueprints/who/who_model.py | 7 +++++-- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/covid19/blueprints/europe/europe_model.py b/src/covid19/blueprints/europe/europe_model.py index 8b69f5f8..75a9ad54 100644 --- a/src/covid19/blueprints/europe/europe_model.py +++ b/src/covid19/blueprints/europe/europe_model.py @@ -9,11 +9,14 @@ class EuropeDateReported(CommonDateReported): __mapper_args__ = { 'concrete': True } + __table_args__ = ( + db.UniqueConstraint('date_reported', 'year_week', 'datum', name="uix_europe_date_reported"), + ) id = db.Column(db.Integer, primary_key=True) date_reported = db.Column(db.String(255), nullable=False, unique=True) - year_week = db.Column(db.String(255), nullable=False) - datum = db.Column(db.Date, nullable=False) + year_week = db.Column(db.String(255), nullable=False, unique=True) + datum = db.Column(db.Date, nullable=False, unique=True) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) day_of_month = db.Column(db.Integer, nullable=False) diff --git a/src/covid19/blueprints/rki/rki_model.py b/src/covid19/blueprints/rki/rki_model.py index 93de52a1..4a19f64c 100644 --- a/src/covid19/blueprints/rki/rki_model.py +++ b/src/covid19/blueprints/rki/rki_model.py @@ -11,11 +11,14 @@ class RkiDateReported(CommonDateReported): __mapper_args__ = { 'concrete': True } + __table_args__ = ( + db.UniqueConstraint('date_reported', 'year_week', 'datum', name="uix_rki_date_reported"), + ) id = db.Column(db.Integer, primary_key=True) date_reported = db.Column(db.String(255), nullable=False, unique=True) - year_week = db.Column(db.String(255), nullable=False) - datum = db.Column(db.Date, nullable=False) + year_week = db.Column(db.String(255), nullable=False, unique=True) + datum = db.Column(db.Date, nullable=False, unique=True) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) day_of_month = db.Column(db.Integer, nullable=False) diff --git a/src/covid19/blueprints/vaccination/vaccination_model.py b/src/covid19/blueprints/vaccination/vaccination_model.py index 0bd6a69b..20c872e6 100644 --- a/src/covid19/blueprints/vaccination/vaccination_model.py +++ b/src/covid19/blueprints/vaccination/vaccination_model.py @@ -9,11 +9,14 @@ class VaccinationDateReported(CommonDateReported): __mapper_args__ = { 'concrete': True } + __table_args__ = ( + db.UniqueConstraint('date_reported', 'year_week', 'datum', name="uix_vaccination_date_reported"), + ) id = db.Column(db.Integer, primary_key=True) - date_reported = db.Column(db.String(255), nullable=False) - year_week = db.Column(db.String(255), nullable=False) - datum = db.Column(db.Date, nullable=False) + date_reported = db.Column(db.String(255), nullable=False, unique=True) + year_week = db.Column(db.String(255), nullable=False, unique=True) + datum = db.Column(db.Date, nullable=False, unique=True) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) day_of_month = db.Column(db.Integer, nullable=False) diff --git a/src/covid19/blueprints/vaccination/vaccination_service_update.py b/src/covid19/blueprints/vaccination/vaccination_service_update.py index db4298a0..62b8f967 100644 --- a/src/covid19/blueprints/vaccination/vaccination_service_update.py +++ b/src/covid19/blueprints/vaccination/vaccination_service_update.py @@ -48,7 +48,7 @@ class VaccinationServiceUpdate: if europe_date_reported is None: o = VaccinationDateReported.create_new_object_factory(item_date_rep) europe_date_reported = o - result_europe_data_import = VaccinationImport.find_by_datum(europe_date_reported) + result_europe_data_import = VaccinationImport.find_by_datum(europe_date_reported.date_reported) for item_europe_data_import in result_europe_data_import: o = VaccinationData( date_reported=europe_date_reported, @@ -92,7 +92,7 @@ class VaccinationServiceUpdate: result_date_rep = VaccinationImport.get_daterep_missing_in_vaccination_data() i = 0 for item_date_rep in result_date_rep: - europe_date_reported = VaccinationDateReported.create_new_object_factory(item_date_rep['date_rep']) + europe_date_reported = VaccinationDateReported.create_new_object_factory(item_date_rep) result_europe_data_import = VaccinationImport.find_by_datum(europe_date_reported) for item_europe_data_import in result_europe_data_import: o = VaccinationData( diff --git a/src/covid19/blueprints/who/who_model.py b/src/covid19/blueprints/who/who_model.py index 126191b8..a1871c94 100644 --- a/src/covid19/blueprints/who/who_model.py +++ b/src/covid19/blueprints/who/who_model.py @@ -10,11 +10,14 @@ class WhoDateReported(CommonDateReported): __mapper_args__ = { 'concrete': True } + __table_args__ = ( + db.UniqueConstraint('date_reported', 'year_week', 'datum', name="uix_who_date_reported"), + ) id = db.Column(db.Integer, primary_key=True) date_reported = db.Column(db.String(255), nullable=False, unique=True) - year_week = db.Column(db.String(255), nullable=False) - datum = db.Column(db.Date, nullable=False) + year_week = db.Column(db.String(255), nullable=False, unique=True) + datum = db.Column(db.Date, nullable=False, unique=True) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) day_of_month = db.Column(db.Integer, nullable=False) -- GitLab