diff --git a/src/covid19/blueprints/ecdc/ecdc_model.py b/src/covid19/blueprints/ecdc/ecdc_model.py index 067c8a2ea0ae84f8caf37f4fedb4e4fddd2c0e7e..055aac10dff6b609fd8759f6efa140fd8484e49b 100644 --- a/src/covid19/blueprints/ecdc/ecdc_model.py +++ b/src/covid19/blueprints/ecdc/ecdc_model.py @@ -22,10 +22,10 @@ class EcdcDateReported(ApplicationDateReported): week_of_year = db.Column(db.Integer, nullable=False) def get_name_for_datum(self): - return self.date_reported + return self.date_reported_import_str def get_date_import_format_from_date_reported(self): - my_date_parts = self.date_reported.split("-") + my_date_parts = self.date_reported_import_str.split("-") my_year = my_date_parts[0] my_month = my_date_parts[1] my_day = my_date_parts[2] @@ -59,12 +59,12 @@ class EcdcDateReported(ApplicationDateReported): @classmethod def create_new_object_factory(cls, my_date_rep: str): (my_year, my_month, my_day) = cls.get_datum_parts(my_date_rep) - date_reported = super().get_datum_as_str(my_year, my_month, my_day) + date_reported_import_str = super().get_datum_as_str(my_year, my_month, my_day) my_datum = super().get_datum(my_year, my_month, my_day) (my_iso_year, week_number, weekday) = my_datum.isocalendar() my_year_week = super().my_year_week(my_iso_year, week_number) return EcdcDateReported( - date_reported_import_str=date_reported, + date_reported_import_str=date_reported_import_str, datum=my_datum, year=my_datum.year, month=my_datum.month, @@ -195,15 +195,17 @@ class EcdcData(db.Model): ecdc_country_id = db.Column(db.Integer, db.ForeignKey('ecdc_country.id'), nullable=False) ecdc_country = db.relationship( 'EcdcCountry', - lazy='subquery', cascade="all, delete", + lazy='subquery', + cascade='save-update', order_by='asc(EcdcCountry.countries_and_territories)' ) ecdc_datereported_id = db.Column(db.Integer, db.ForeignKey('ecdc_datereported.id'), nullable=False) ecdc_datereported = db.relationship( 'EcdcDateReported', - lazy='joined', cascade='all, delete', - order_by='desc(EcdcDateReported.date_reported)' + lazy='joined', + cascade='save-update', + order_by='desc(EcdcDateReported.date_reported_import_str)' ) @classmethod diff --git a/src/covid19/blueprints/owid/owid_model.py b/src/covid19/blueprints/owid/owid_model.py index 2d5e529bb6cc8a2213870760802aa8b2ec75fa39..3aa699452fc036e1c6b56eb67c0a811ee630ffbf 100644 --- a/src/covid19/blueprints/owid/owid_model.py +++ b/src/covid19/blueprints/owid/owid_model.py @@ -64,7 +64,7 @@ class OwidCountry(db.Model): continent = db.relationship( 'OwidContinent', lazy='joined', - cascade='all, delete', + cascade='save-update', order_by='desc(OwidContinent.region)') iso_code = db.Column(db.String(255), nullable=False) location = db.Column(db.String(255), nullable=False) @@ -137,14 +137,14 @@ class OwidData(db.Model): date_reported = db.relationship( 'OwidDateReported', lazy='joined', - cascade='all, delete', - order_by='desc(OwidDateReported.date_reported)') + cascade='save-update', + order_by='desc(OwidDateReported.date_reported_import_str)') country_id = db.Column(db.Integer, db.ForeignKey('owid_country.id'), nullable=False) country = db.relationship( 'OwidCountry', lazy='joined', - cascade='all, delete', + cascade='save-update', order_by='desc(OwidCountry.location)') total_cases = db.Column(db.String(255), nullable=False) new_cases = db.Column(db.String(255), nullable=False) diff --git a/src/covid19/blueprints/rki/rki_vaccination/rki_vaccination_model.py b/src/covid19/blueprints/rki/rki_vaccination/rki_vaccination_model.py index f90e5f991da36618252d4ac1c8c87cef379df4fb..b68f57bcb414616b6aa17e3b87d965bcb640c48b 100644 --- a/src/covid19/blueprints/rki/rki_vaccination/rki_vaccination_model.py +++ b/src/covid19/blueprints/rki/rki_vaccination/rki_vaccination_model.py @@ -53,8 +53,8 @@ class RkiVaccinationData(db.Model): date_reported = db.relationship( 'RkiVaccinationDateReported', lazy='joined', - cascade='all, delete', - order_by='desc(RkiVaccinationDateReported.date_reported)') + cascade='save-update', + order_by='desc(RkiVaccinationDateReported.date_reported_import_str)') dosen_kumulativ = db.Column(db.Integer, nullable=False) dosen_differenz_zum_vortag = db.Column(db.Integer, nullable=False) dosen_biontech_kumulativ = db.Column(db.Integer, nullable=False) diff --git a/src/covid19/blueprints/who/who_model.py b/src/covid19/blueprints/who/who_model.py index b75afba53f465712e6f5b515d2590e7bd13829e9..298b7cae95c376171cdb1b446d8910d64c15f7b6 100644 --- a/src/covid19/blueprints/who/who_model.py +++ b/src/covid19/blueprints/who/who_model.py @@ -190,7 +190,7 @@ class WhoData(db.Model): 'WhoDateReported', lazy='joined', cascade='save-update', - order_by='desc(WhoDateReported.date_reported)') + order_by='desc(WhoDateReported.date_reported_import_str)') country_id = db.Column(db.Integer, db.ForeignKey('who_country.id'), nullable=False) country = db.relationship(