diff --git a/src/flask_covid19/blueprints/app_all/all_model.py b/src/flask_covid19/blueprints/app_all/all_model.py index 24902dedf57f7a02c50299390c84f8eb3640bca3..bf95b89607ac3aa50def402e9cd96f1295bd9b4f 100644 --- a/src/flask_covid19/blueprints/app_all/all_model.py +++ b/src/flask_covid19/blueprints/app_all/all_model.py @@ -2,15 +2,13 @@ from datetime import date, datetime from database import db, cache, ITEMS_PER_PAGE -class ApplicationDateReported(db.Model): - __tablename__ = 'application_datereported' +class BlueprintDateReported(db.Model): + __tablename__ = 'blueprint_date_reported' __table_args__ = ( - db.UniqueConstraint('date_reported_import_str', 'datum', name="uix_application_datereported"), + db.UniqueConstraint('date_reported_import_str', 'datum', name="uix_blueprint_date_reported"), ) # id = db.Column(db.Integer, primary_key=True) - date_reported_import_str = 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, unique=True) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) @@ -18,7 +16,9 @@ class ApplicationDateReported(db.Model): day_of_week = db.Column(db.Integer, nullable=False) week_of_year = db.Column(db.Integer, nullable=False) day_of_year = db.Column(db.Integer, nullable=True) + year_week = db.Column(db.String(255), nullable=False) year_day_of_year = db.Column(db.String(255), nullable=True, unique=True) + date_reported_import_str = db.Column(db.String(255), nullable=False, unique=True) def __str__(self): result = "" @@ -87,7 +87,7 @@ class ApplicationDateReported(db.Model): my_year_week = cls.my_year_week(my_iso_year, week_number) day_of_year = 0 year_day_of_year = str() + "-" + str(my_datum.year) - return ApplicationDateReported( + return BlueprintDateReported( date_reported_import_str=date_reported_import_str, datum=my_datum, year=my_datum.year, @@ -172,16 +172,16 @@ class ApplicationDateReported(db.Model): .first() -class ApplicationRegion(db.Model): - __tablename__ = 'application_region' +class BlueprintLocationGroup(db.Model): + __tablename__ = 'blueprint_location_group' __table_args__ = ( - db.UniqueConstraint('region', name='uix_application_region'), + db.UniqueConstraint('region', name='uix_blueprint_location_group'), ) id = db.Column(db.Integer, primary_key=True) - region = db.Column(db.String(255), nullable=False, unique=True) + location_group = db.Column(db.String(255), nullable=False, unique=True) def __str__(self): - result = " " + self.region + " " + result = " " + self.location_group + " " return result @classmethod @@ -236,3 +236,16 @@ class ApplicationRegion(db.Model): return db.session.query(cls)\ .filter(cls.region == i_region)\ .one_or_none() + + +class BlueprintLocation(db.Model): + __tablename__ = 'blueprint_location' + __table_args__ = ( + db.UniqueConstraint('region', name='uix_blueprint_location'), + ) + id = db.Column(db.Integer, primary_key=True) + location = db.Column(db.String(255), nullable=False, unique=True) + + def __str__(self): + result = " " + self.location + " " + return result diff --git a/src/flask_covid19/blueprints/data_divi/divi_model.py b/src/flask_covid19/blueprints/data_divi/divi_model.py index 1ffd5c4848ddc5e4aab32b85f396bdee5e39cf58..91d62b3c8aa28f72b3d0c20e00c28e7eaf120280 100644 --- a/src/flask_covid19/blueprints/data_divi/divi_model.py +++ b/src/flask_covid19/blueprints/data_divi/divi_model.py @@ -2,10 +2,10 @@ from sqlalchemy import and_ from datetime import date from sqlalchemy.orm import joinedload, subqueryload from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported, ApplicationRegion +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported, BlueprintLocationGroup -class DiviDateReported(ApplicationDateReported): +class DiviDateReported(BlueprintDateReported): __tablename__ = 'divi_datereported' __mapper_args__ = {'concrete': True} __table_args__ = ( @@ -44,7 +44,7 @@ class DiviDateReported(ApplicationDateReported): ) -class DiviRegion(ApplicationRegion): +class DiviRegion(BlueprintLocationGroup): __tablename__ = 'divi_country_region' __mapper_args__ = {'concrete': True} __table_args__ = ( diff --git a/src/flask_covid19/blueprints/data_ecdc/ecdc_model.py b/src/flask_covid19/blueprints/data_ecdc/ecdc_model.py index f23c7298da066e8dfa45d1772a1474554162822a..5cab360b52b557a046c234b2d92fb0867725e7c0 100644 --- a/src/flask_covid19/blueprints/data_ecdc/ecdc_model.py +++ b/src/flask_covid19/blueprints/data_ecdc/ecdc_model.py @@ -1,9 +1,9 @@ from sqlalchemy import and_ from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported, ApplicationRegion +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported, BlueprintLocationGroup -class EcdcDateReported(ApplicationDateReported): +class EcdcDateReported(BlueprintDateReported): __tablename__ = 'ecdc_datereported' __mapper_args__ = {'concrete': True} __table_args__ = ( @@ -74,7 +74,7 @@ class EcdcDateReported(ApplicationDateReported): ) -class EcdcContinent(ApplicationRegion): +class EcdcContinent(BlueprintLocationGroup): __tablename__ = 'ecdc_country_continent' __mapper_args__ = {'concrete': True} __table_args__ = ( diff --git a/src/flask_covid19/blueprints/data_owid/owid_model.py b/src/flask_covid19/blueprints/data_owid/owid_model.py index f7fa784c40da1e2a57f7d55506610694d56eb0f0..23add262390ee810f3d13edb6dbc872e8c3fc189 100644 --- a/src/flask_covid19/blueprints/data_owid/owid_model.py +++ b/src/flask_covid19/blueprints/data_owid/owid_model.py @@ -3,10 +3,10 @@ from datetime import date from sqlalchemy.orm import joinedload, subqueryload from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported, ApplicationRegion +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported, BlueprintLocationGroup -class OwidDateReported(ApplicationDateReported): +class OwidDateReported(BlueprintDateReported): __tablename__ = 'owid_datereported' __mapper_args__ = {'concrete': True} __table_args__ = ( @@ -90,7 +90,7 @@ class OwidDateReported(ApplicationDateReported): ) -class OwidContinent(ApplicationRegion): +class OwidContinent(BlueprintLocationGroup): __tablename__ = 'owid_country_continent' __mapper_args__ = {'concrete': True} __table_args__ = ( diff --git a/src/flask_covid19/blueprints/data_rki_cases/rki_model.py b/src/flask_covid19/blueprints/data_rki_cases/rki_model.py index 5080047b6acb7a42cf1c2802a372ef768a886732..192e6b7f172e80e4d9d5f09daf0005e0ec6f167a 100644 --- a/src/flask_covid19/blueprints/data_rki_cases/rki_model.py +++ b/src/flask_covid19/blueprints/data_rki_cases/rki_model.py @@ -2,10 +2,10 @@ from sqlalchemy import and_ from datetime import date from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported, ApplicationRegion +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported, BlueprintLocationGroup -class RkiMeldedatum(ApplicationDateReported): +class RkiMeldedatum(BlueprintDateReported): __tablename__ = 'rki_cases_datereported' __mapper_args__ = {'concrete': True} __table_args__ = ( @@ -44,7 +44,7 @@ class RkiMeldedatum(ApplicationDateReported): ) -class RkiBundesland(ApplicationRegion): +class RkiBundesland(BlueprintLocationGroup): __tablename__ = 'rki_cases_landkreis_bundesland' __mapper_args__ = {'concrete': True} __table_args__ = ( diff --git a/src/flask_covid19/blueprints/data_rki_vaccination/rki_vaccination_model.py b/src/flask_covid19/blueprints/data_rki_vaccination/rki_vaccination_model.py index 01bc38161630399d80329bb53789b0ff00d0575b..fed400008a33ae31f8fccc721bf48093f69b5a12 100644 --- a/src/flask_covid19/blueprints/data_rki_vaccination/rki_vaccination_model.py +++ b/src/flask_covid19/blueprints/data_rki_vaccination/rki_vaccination_model.py @@ -1,10 +1,10 @@ from datetime import date from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported -class RkiVaccinationDateReported(ApplicationDateReported): +class RkiVaccinationDateReported(BlueprintDateReported): __tablename__ = 'rki_vaccination_datereported' __mapper_args__ = { 'concrete': True diff --git a/src/flask_covid19/blueprints/data_who/who_model.py b/src/flask_covid19/blueprints/data_who/who_model.py index 06604ffb4bedb6f822469ebd991ec1e0d86ded37..e22b4fc81e081611e8a9e04170eb779576285c1f 100644 --- a/src/flask_covid19/blueprints/data_who/who_model.py +++ b/src/flask_covid19/blueprints/data_who/who_model.py @@ -2,10 +2,10 @@ from sqlalchemy import and_ from datetime import date from sqlalchemy.orm import joinedload, subqueryload from database import db, ITEMS_PER_PAGE -from flask_covid19.blueprints.app_all.all_model import ApplicationDateReported, ApplicationRegion +from flask_covid19.blueprints.app_all.all_model import BlueprintDateReported, BlueprintLocationGroup -class WhoDateReported(ApplicationDateReported): +class WhoDateReported(BlueprintDateReported): __tablename__ = 'who_datereported' __mapper_args__ = {'concrete': True} __table_args__ = ( @@ -44,7 +44,7 @@ class WhoDateReported(ApplicationDateReported): ) -class WhoCountryRegion(ApplicationRegion): +class WhoCountryRegion(BlueprintLocationGroup): __tablename__ = 'who_country_region' __mapper_args__ = {'concrete': True} __table_args__ = (