diff --git a/data b/data index 538f97de8278cd7f649d6d2a5078a7e88978e7e9..26f6305db08aa3cd736f69c83127cde3a1f9c120 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 538f97de8278cd7f649d6d2a5078a7e88978e7e9 +Subproject commit 26f6305db08aa3cd736f69c83127cde3a1f9c120 diff --git a/src/covid19/blueprints/application/application_service_config.py b/src/covid19/blueprints/application/application_service_config.py index f073ef9010dda5913d5c7ee6e1bd578156849745..5ca420ae309b0d2ec8bb400b32d32e12dd84b255 100644 --- a/src/covid19/blueprints/application/application_service_config.py +++ b/src/covid19/blueprints/application/application_service_config.py @@ -87,8 +87,8 @@ class ApplicationServiceConfig: cvsfile_subpath='rki' + os.sep + 'rki_bundeslaender', sub_category='Bundeslaender', tablename=RkiBundeslaenderImport.__tablename__, - cvsfile_name="RKI_COVID19__" + date.today().isoformat() + "__bundeslaender.csv", - url_src="https://opendata.arcgis.com/datasets/ef4b445a53c1406892257fe63129a8ea_0.csv", + cvsfile_name="RKI_COVID19__" + date.today().isoformat() + "__Fallzahlen_Kum_Tab.xlsx", + url_src="https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Fallzahlen_Kum_Tab.xlsx?__blob=publicationFile", ) @classmethod @@ -102,3 +102,15 @@ class ApplicationServiceConfig: cvsfile_name="RKI_COVID19__" + date.today().isoformat() + "__landkreise.csv", url_src="https://opendata.arcgis.com/datasets/917fc37a709542548cc3be077a786c17_0.csv", ) + + @classmethod + def create_config_for_intensivregister(cls): + return ApplicationServiceConfig( + slug='intensivregister', + category='DIVI', + cvsfile_subpath='intensivregister', + sub_category='Intensivregister', + tablename=RkiLandkreiseImport.__tablename__, + cvsfile_name="DIVI_intensivregister.json", + url_src="https://www.intensivregister.de/api/public/intensivregister", + ) diff --git a/src/covid19/blueprints/application/application_services.py b/src/covid19/blueprints/application/application_services.py index 4c13000b2a3e9da2057c49ff8ceecdc308515582..514cfb76ac4c8de2204a887a43ce5a115786176a 100644 --- a/src/covid19/blueprints/application/application_services.py +++ b/src/covid19/blueprints/application/application_services.py @@ -8,7 +8,7 @@ from covid19.blueprints.rki.rki_landkreise.rki_landkreise_service import RkiLand from covid19.blueprints.rki.rki_vaccination.rki_vaccination_service import RkiVaccinationService from covid19.blueprints.who.who_service import WhoService from covid19.blueprints.user.user_service import UserService - +from covid19.blueprints.intensivregister.divi_service import DiviService ############################################################################################ # @@ -22,4 +22,5 @@ rki_service_landkreise = RkiLandkreiseService(db) rki_vaccination_service = RkiVaccinationService(db) who_service = WhoService(db) user_service = UserService(db) +divi_service = DiviService(db) db.create_all() diff --git a/src/covid19/blueprints/application/application_views.py b/src/covid19/blueprints/application/application_views.py index a3e7886cd7014e505e6f58b2abe10ecaa7dc10da..758e28cd84189d9298a1bc5faedd70696fb3d13b 100644 --- a/src/covid19/blueprints/application/application_views.py +++ b/src/covid19/blueprints/application/application_views.py @@ -11,6 +11,7 @@ from covid19.blueprints.rki.rki_vaccination.rki_vaccination_views import app_rki from covid19.blueprints.who.who_views import app_who from covid19.blueprints.owid.owid_views import app_owid from covid19.blueprints.user.user_views import app_user +from covid19.blueprints.intensivregister.divi_views import app_divi from covid19.blueprints.owid_test.owid_test_views import app_owid_test @@ -27,6 +28,7 @@ app.register_blueprint(app_rki_vaccination, url_prefix='/rki/vaccination') app.register_blueprint(app_who, url_prefix='/who') app.register_blueprint(app_owid, url_prefix='/owid') app.register_blueprint(app_user, url_prefix='/usr') +app.register_blueprint(app_divi, url_prefix='/divi') app.register_blueprint(app_owid_test, url_prefix='/owid/test') app.register_blueprint(app_who_test, url_prefix='/who/test') diff --git a/src/covid19/blueprints/intensivregister/__init__.py b/src/covid19/blueprints/intensivregister/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/covid19/blueprints/intensivregister/divi_model.py b/src/covid19/blueprints/intensivregister/divi_model.py new file mode 100644 index 0000000000000000000000000000000000000000..9f3952e62de2df30754c5cf3388545da3b31440b --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_model.py @@ -0,0 +1,358 @@ +from sqlalchemy import and_ +from datetime import date +from sqlalchemy.orm import joinedload, subqueryload +from database import db, ITEMS_PER_PAGE +from covid19.blueprints.application.application_model import ApplicationDateReported, ApplicationRegion + + +class DiviDateReported(ApplicationDateReported): + __tablename__ = 'divi_datereported' + __mapper_args__ = {'concrete': True} + __table_args__ = ( + db.UniqueConstraint('date_reported_import_str', 'datum', name="uix_divi_datereported"), + ) + + 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) + day_of_month = db.Column(db.Integer, nullable=False) + day_of_week = db.Column(db.Integer, nullable=False) + week_of_year = db.Column(db.Integer, nullable=False) + + @classmethod + def create_new_object_factory(cls, my_date_rep): + my_datum = date.fromisoformat(my_date_rep) + (my_iso_year, week_number, weekday) = my_datum.isocalendar() + my_year_week = "" + str(my_iso_year) + if week_number < 10: + my_year_week += "-0" + else: + my_year_week += "-" + my_year_week += str(week_number) + return DiviDateReported( + date_reported_import_str=my_date_rep, + datum=my_datum, + year=my_datum.year, + month=my_datum.month, + day_of_month=my_datum.day, + day_of_week=weekday, + week_of_year=week_number, + year_week=my_year_week + ) + + +class DiviRegion(ApplicationRegion): + __tablename__ = 'divi_country_region' + __mapper_args__ = {'concrete': True} + __table_args__ = ( + db.UniqueConstraint('region', name="uix_divi_country_region"), + ) + + id = db.Column(db.Integer, primary_key=True) + region = db.Column(db.String(255), nullable=False, unique=True) + + +class DiviCountry(db.Model): + __tablename__ = 'divi_country' + __table_args__ = ( + db.UniqueConstraint('country_code', 'country', name="uix_divi_country"), + ) + + id = db.Column(db.Integer, primary_key=True) + country_code = db.Column(db.String(255), unique=True, nullable=False) + country = db.Column(db.String(255), unique=True, nullable=False) + region_id = db.Column(db.Integer, db.ForeignKey('divi_country_region.id'), nullable=False) + region = db.relationship( + 'DiviRegion', + lazy='joined', + cascade='save-update', + order_by='DiviRegion.region') + + def __str__(self): + result = "" + result += self.country_code + result += " " + result += self.country + result += " " + result += self.region.region + result += " " + return result + + @classmethod + def remove_all(cls): + for one in cls.get_all(): + db.session.delete(one) + db.session.commit() + return None + + @classmethod + def get_all_as_page(cls, page): + return db.session.query(cls)\ + .order_by(cls.country)\ + .paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_all(cls): + return db.session.query(cls)\ + .order_by(cls.country)\ + .all() + + @classmethod + def get_all_as_dict(cls): + countries = {} + for my_country in cls.get_all(): + countries[my_country.country_code] = my_country + return countries + + @classmethod + def get_by_id(cls, other_id): + return db.session.query(cls)\ + .filter(cls.id == other_id)\ + .one() + + @classmethod + def get_germany(cls): + return db.session.query(cls)\ + .filter(cls.country_code == 'DE')\ + .one_or_none() + + @classmethod + def find_by_country_code_and_country_and_who_region_id(cls, i_country_code, i_country, my_region): + return db.session.query(cls).filter( + and_( + cls.country_code == i_country_code, + cls.country == i_country, + cls.region_id == my_region.id + ) + ).one_or_none() + + @classmethod + def find_by_country_code(cls, i_country_code): + return db.session.query(cls).filter( + cls.country_code == i_country_code + ).one_or_none() + + @classmethod + def find_by_country(cls, i_country): + return db.session.query(cls).filter( + cls.country == i_country + ).one_or_none() + + @classmethod + def get_by_country_code(cls, i_country_code): + return db.session.query(cls).filter( + cls.country_code == i_country_code + ).one() + + @classmethod + def get_by_country(cls, i_country): + return db.session.query(cls).filter( + cls.country == i_country + ).one() + + @classmethod + def get_who_countries_for_region(cls, region, page): + return db.session.query(cls).filter( + cls.region == region + ).order_by(cls.country).paginate(page, per_page=ITEMS_PER_PAGE) + + +class DiviData(db.Model): + __tablename__ = 'divi' + + id = db.Column(db.Integer, primary_key=True) + cases_new = db.Column(db.Integer, nullable=False) + cases_cumulative = db.Column(db.Integer, nullable=False) + deaths_new = db.Column(db.Integer, nullable=False) + deaths_cumulative = db.Column(db.Integer, nullable=False) + date_reported_id = db.Column(db.Integer, + db.ForeignKey('divi_datereported.id'), nullable=False) + date_reported = db.relationship( + 'DiviDateReported', + lazy='joined', + cascade='save-update', + order_by='desc(DiviDateReported.date_reported_import_str)') + country_id = db.Column(db.Integer, + db.ForeignKey('divi_country.id'), nullable=False) + country = db.relationship( + 'DiviCountry', + lazy='joined', + cascade='save-update', + order_by='asc(DiviCountry.country)') + + @classmethod + def remove_all(cls): + for one in cls.get_all(): + db.session.delete(one) + db.session.commit() + return None + + @classmethod + def get_all_as_page(cls, page): + return db.session.query(cls).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_all(cls): + return db.session.query(cls).all() + + @classmethod + def get_by_id(cls, other_id): + return db.session.query(cls).filter(cls.id == other_id).one() + + @classmethod + def find_one_or_none_by_date_and_country(cls, my_date_reported, my_country): + return db.session.query(cls).filter( + and_( + cls.date_reported_id == my_date_reported.id, + cls.country_id == my_country.id + ) + ).one_or_none() + + @classmethod + def get_data_for_country(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc(), + cls.cases_new.desc(), + cls.deaths_cumulative.desc(), + cls.cases_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_one_day(cls, date_reported): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc(), + cls.cases_new.desc(), + cls.deaths_cumulative.desc(), + cls.cases_cumulative.desc() + ).all() + + @classmethod + def delete_data_for_one_day(cls, date_reported): + for one_who_date in cls.get_data_for_one_day(date_reported): + db.session.delete(one_who_date) + db.session.commit() + return None + + @classmethod + def get_data_for_day_order_by_cases_new(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_cases_cumulative(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_deaths_new(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_deaths_cumulative(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_cases_new(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_cases_cumulative(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_deaths_new(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_deaths_cumulative(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).joinedload(DiviCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_datum_of_all_data(cls): + datum_of_all_who_data = [] + for data in db.session.query(cls).options(subqueryload("date_reported").load_only("date_reported_import_str")): + datum = data.date_reported.date_reported_import_str + if not datum in datum_of_all_who_data: + datum_of_all_who_data.append(datum) + datum_of_all_who_data.sort() + return datum_of_all_who_data + + @classmethod + def get_joungest_datum(cls): + return cls.get_datum_of_all_who_data().pop() diff --git a/src/covid19/blueprints/intensivregister/divi_model_import.py b/src/covid19/blueprints/intensivregister/divi_model_import.py new file mode 100644 index 0000000000000000000000000000000000000000..fcbdda1a7a8d65dd40b35ed8c2fc58658fde2de5 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_model_import.py @@ -0,0 +1,165 @@ +from sqlalchemy.orm import Bundle +from database import db, ITEMS_PER_PAGE + + +class DiviImport(db.Model): + __tablename__ = 'application__import__divi' + + id = db.Column(db.Integer, primary_key=True) + date_reported = db.Column(db.String(255), nullable=False) + country_code = db.Column(db.String(255), nullable=False) + country = db.Column(db.String(255), nullable=False) + who_region = db.Column(db.String(255), nullable=False) + new_cases = db.Column(db.String(255), nullable=False) + cumulative_cases = db.Column(db.String(255), nullable=False) + new_deaths = db.Column(db.String(255), nullable=False) + cumulative_deaths = db.Column(db.String(255), nullable=False) + + @classmethod + def remove_all(cls): + for one in cls.get_all(): + db.session.delete(one) + db.session.commit() + return None + + @classmethod + def get_all_as_page(cls, page): + return db.session.query(cls).order_by( + cls.date_reported.desc(), + cls.country.asc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_all(cls): + return db.session.query(cls).order_by( + cls.date_reported.desc(), + cls.country.asc() + ).all() + + @classmethod + def get_by_id(cls, other_id): + return db.session.query(cls)\ + .filter(cls.id == other_id)\ + .one() + + @classmethod + def get_regions(cls): + return db.session.query(cls.who_region)\ + .order_by(cls.who_region)\ + .distinct().all() + + @classmethod + def get_dates_reported(cls): + return db.session.query(cls.date_reported)\ + .order_by(cls.date_reported.desc())\ + .distinct().all() + + @classmethod + def get_for_one_day(cls, day): + return db.session.query(cls)\ + .filter(cls.date_reported == day)\ + .order_by(cls.country.asc())\ + .all() + + @classmethod + def get_dates_reported_as_array(cls): + myresultarray = [] + myresultset = db.session.query(cls.date_reported)\ + .order_by(cls.date_reported.desc())\ + .group_by(cls.date_reported)\ + .distinct() + for item, in myresultset: + pass + return myresultarray + + @classmethod + def __get_new_dates_as_array_sql(cls): + # TODO: #83 WhoImport.get_new_dates_as_array() SQLalchemy instead of SQL + sql_query = """ + select + distinct + application__import__divi.date_reported + from + application__import__divi + where + date_reported + not in ( + select + distinct + divi_datereported.date_reported_import_str + from + divi + left join + divi_datereported + on + divi.date_reported_id=divi_datereported.id + group by + divi_datereported.date_reported_import_str + order by + divi_datereported.date_reported_import_str desc + ) + group by + application__import__divi.date_reported + order by + application__import__divi.date_reported desc + """ + new_dates = [] + for item in db.session.execute(sql_query): + new_dates.append(item['date_reported']) + return new_dates + + @classmethod + def __get_new_dates_as_array_orm(cls): + # TODO: #83 WhoImport.get_new_dates_as_array() SQLalchemy instead of SQL + sql_query = """ + select + distinct + application__import__divi.date_reported + from + application__import__divi + where + date_reported + not in ( + select + distinct + divi_datereported.date_reported_import_str + from + divi + left join + divi_datereported + on + divi.date_reported_id=divi_datereported.id + group by + divi_datereported.date_reported_import_str + order by + divi_datereported.date_reported_import_str desc + ) + group by + application__import__divi.date_reported + order by + application__import__divi.date_reported desc + """ + new_dates = [] + for item in db.session.execute(sql_query): + new_dates.append(item['date_reported']) + return new_dates + + @classmethod + def get_new_dates_as_array(cls): + #return cls.__get_new_dates_as_array_sql() + return cls.__get_new_dates_as_array_orm() + + @classmethod + def countries(cls): + bu = Bundle('countries', cls.country_code, cls.country, cls.who_region) + return db.session.query(bu).distinct() + + @classmethod + def get_datum_of_all_who_import(cls): + dates_reported = [] + bu = Bundle('dates_reported', cls.date_reported) + for date_reported in db.session.query(bu).distinct().order_by(cls.date_reported): + item = date_reported[0][0] + if not item in dates_reported: + dates_reported.append(item) + return dates_reported diff --git a/src/covid19/blueprints/intensivregister/divi_service.py b/src/covid19/blueprints/intensivregister/divi_service.py new file mode 100644 index 0000000000000000000000000000000000000000..7b57959322e84681885c4f479c50463abb37b8f8 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_service.py @@ -0,0 +1,95 @@ +from flask import flash + +from database import app +from covid19.blueprints.application.application_service_config import ApplicationServiceConfig +from covid19.blueprints.application.application_service_download import ApplicationServiceDownload +from covid19.blueprints.intensivregister.divi_service_import import DiviServiceImport +from covid19.blueprints.intensivregister.divi_service_update import DiviServiceUpdate + + +class DiviService: + def __init__(self, database): + app.logger.debug("------------------------------------------------------------") + app.logger.debug(" DIVI Service [init]") + app.logger.debug("------------------------------------------------------------") + self.__database = database + self.cfg = ApplicationServiceConfig.create_config_for_intensivregister() + self.service_download = ApplicationServiceDownload(database, self.cfg) + self.service_import = DiviServiceImport(database, self.cfg) + self.service_update = DiviServiceUpdate(database, self.cfg) + app.logger.debug("------------------------------------------------------------") + app.logger.info(" DIVI Service [ready]") + + def pretask_database_drop_create(self): + flash("DiviService.pretask_database_drop_create started") + app.logger.info("DiviService.pretask_database_drop_create started") + self.service_download.download_file() + app.logger.info("DiviService.pretask_database_drop_create done") + flash("DiviService.pretask_database_drop_create done") + return self + + def task_database_drop_create(self): + app.logger.info("DiviService.task_database_drop_create started") + self.service_import.import_file() + self.service_update.update_dimension_tables_only() + self.service_update.update_fact_table_incremental_only() + app.logger.info("DiviService.task_database_drop_create done") + return self + + #def run_download_only(self): + #def run_import_only(self): + #def run_update_dimension_tables_only(self): + #def run_update_fact_table_incremental_only(self): + #def run_update_fact_table_initial_only(self): + #def run_update_star_schema_incremental(self): + #def run_update_star_schema_initial(self): + + def run_download_only(self): + self.service_download.download_file() + return self + + def run_import_only(self): + self.service_import.import_file() + return self + + def run_update_dimension_tables_only(self): + self.service_update.update_dimension_tables_only() + return self + + def run_update_fact_table_incremental_only(self): + self.service_update.update_fact_table_incremental_only() + return self + + def run_update_fact_table_initial_only(self): + self.service_update.update_fact_table_initial_only() + return self + + def run_update_star_schema_incremental(self): + self.service_import.import_file() + self.service_update.update_star_schema_incremental() + return self + + def run_update_star_schema_initial(self): + self.service_import.import_file() + self.service_update.update_star_schema_initial() + return self + + def download_all_files(self): + self.service_download.download_file() + return self + + def task_import_all_files(self): + self.service_import.import_file() + return self + + def update_dimension_tables_only(self): + self.service_update.update_dimension_tables_only() + return self + + def update_fact_table_initial_only(self): + self.service_update.update_fact_table_initial_only() + return self + + def update_fact_table_incremental_only(self): + self.service_update.update_fact_table_incremental_only() + return self diff --git a/src/covid19/blueprints/intensivregister/divi_service_import.py b/src/covid19/blueprints/intensivregister/divi_service_import.py new file mode 100644 index 0000000000000000000000000000000000000000..bf78b119cf32b825853522ca13b0ba9c2ad033c7 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_service_import.py @@ -0,0 +1,68 @@ +import sys +import csv +import psycopg2 +from database import db, app +from covid19.blueprints.intensivregister.divi_model_import import DiviImport +from covid19.blueprints.application.application_service_config import ApplicationServiceConfig + + +class DiviServiceImport: + def __init__(self, database, config: ApplicationServiceConfig): + app.logger.debug("------------------------------------------------------------") + app.logger.debug(" DIVI Service Import [init]") + app.logger.debug("------------------------------------------------------------") + self.__database = database + self.cfg = config + app.logger.debug("------------------------------------------------------------") + app.logger.debug(" DIVI Service Import [ready]") + + def import_file(self): + app.logger.info(" import DIVI [begin]") + app.logger.info("------------------------------------------------------------") + app.logger.info(" import into TABLE: "+self.cfg.tablename+" from "+self.cfg.cvsfile_path) + app.logger.info("------------------------------------------------------------") + row = None + if sys.platform == 'linux': + keyDate_reported ='\ufeffDate_reported' + else: + keyDate_reported = 'Date_reported' + try: + DiviImport.remove_all() + with open(self.cfg.cvsfile_path, newline='\n') as csv_file: + file_reader = csv.DictReader(csv_file, delimiter=',', quotechar='"') + k = 0 + for row in file_reader: + o = DiviImport( + date_reported=row[keyDate_reported], + country_code=row['Country_code'], + country=row['Country'], + who_region=row['WHO_region'], + new_cases=row['New_cases'], + cumulative_cases=row['Cumulative_cases'], + new_deaths=row['New_deaths'], + cumulative_deaths=row['Cumulative_deaths'] + ) + db.session.add(o) + k += 1 + if (k % 2000) == 0: + db.session.commit() + app.logger.info(" import DIVI ... " + str(k) + " rows") + db.session.commit() + app.logger.info(" import DIVI ... " + str(k) + " rows total") + except KeyError as error: + app.logger.warning("WARN: import DIVI [begin]") + app.logger.warning(":::"+str(error)+":::") + for item_key, item_value in row.items(): + app.logger.warning(item_key+" : "+item_value) + app.logger.warning("WARN: import DIVI [end]") + except (Exception, psycopg2.DatabaseError) as error: + app.logger.warning("WARN: import DIVI [begin]") + app.logger.warning(error) + app.logger.warning("WARN: import DIVI [end]") + finally: + app.logger.info("") + app.logger.info("------------------------------------------------------------") + app.logger.info(" imported into TABLE: "+self.cfg.tablename+" from "+self.cfg.cvsfile_path) + app.logger.info("------------------------------------------------------------") + app.logger.info(" import DIVI [done]") + return self diff --git a/src/covid19/blueprints/intensivregister/divi_service_update.py b/src/covid19/blueprints/intensivregister/divi_service_update.py new file mode 100644 index 0000000000000000000000000000000000000000..0e167c26ddac0998f5223fda62f9c131c8c8fdc3 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_service_update.py @@ -0,0 +1,226 @@ +from database import db, app +from covid19.blueprints.intensivregister.divi_model import DiviRegion, DiviDateReported, DiviCountry, DiviData +from covid19.blueprints.intensivregister.divi_model_import import DiviImport +from covid19.blueprints.application.application_service_config import ApplicationServiceConfig + + +class DiviServiceUpdate: + def __init__(self, database, config: ApplicationServiceConfig): + app.logger.debug("------------------------------------------------------------") + app.logger.debug(" DiviServiceUpdate [init]") + app.logger.debug("------------------------------------------------------------") + self.__database = database + self.cfg = config + app.logger.debug("------------------------------------------------------------") + app.logger.debug(" DiviServiceUpdate [ready]") + + def __update_date_reported(self): + app.logger.info(" DiviServiceUpdate.__update_date_reported [begin]") + app.logger.info("------------------------------------------------------------") + i = 0 + for i_date_reported, in DiviImport.get_dates_reported(): + i += 1 + output = " [ " + str(i) + " ] " + i_date_reported + c = DiviDateReported.find_by_date_reported(i_date_reported) + if c is None: + o = DiviDateReported.create_new_object_factory(my_date_rep=i_date_reported) + db.session.add(o) + db.session.commit() + output += " added" + else: + output += " NOT added "+str(c.id) + app.logger.info(output) + app.logger.info("") + app.logger.info(" DiviServiceUpdate.__update_date_reported [done]") + app.logger.info("------------------------------------------------------------") + return self + + def __update_region(self): + app.logger.info(" DiviServiceUpdate.__update_who_region [begin]") + app.logger.info("------------------------------------------------------------") + i = 0 + for i_who_region, in DiviImport.get_regions(): + i += 1 + output = " [ " + str(i) + " ] " + i_who_region + c = DiviRegion.find_by_region(i_who_region) + if c is None: + o = DiviRegion(region=i_who_region) + db.session.add(o) + db.session.commit() + output += " added" + else: + output += " NOT added ( " + str(c.id) + " ) " + app.logger.info(output) + app.logger.info("") + app.logger.info(" DiviServiceUpdate.__update_who_region [done]") + app.logger.info("------------------------------------------------------------") + return self + + def __update_country(self): + app.logger.info(" DiviServiceUpdate.__update_who_country [begin]") + app.logger.info("------------------------------------------------------------") + result = DiviImport.countries() + i = 0 + for result_item in result: + i += 1 + i_country_code = result_item.countries.country_code + i_country = result_item.countries.country + i_who_region = result_item.countries.who_region + output = " [ " + str(i) + " ] " + i_country_code + " | " + i_country + " | " + i_who_region + " | " + my_region = DiviRegion.find_by_region(i_who_region) + my_country = DiviCountry.find_by_country_code_and_country_and_who_region_id( + i_country_code, i_country, my_region + ) + if my_country is None: + o = DiviCountry( + country=i_country, + country_code=i_country_code, + region=my_region) + db.session.add(o) + db.session.commit() + output2 = " added " + else: + output2 = " NOT added ( " + str(my_country.id) + " ) " + output += i_country_code + output2 + app.logger.info(output) + db.session.commit() + app.logger.info("") + app.logger.info(" DiviServiceUpdate.__update_who_country [done]") + app.logger.info("------------------------------------------------------------") + return self + + def who_import_get_new_dates_as_array(self): + new_dates_reported_from_import = [] + list_datum_of_all_who_data = DiviData.get_datum_of_all_who_data() + for item in DiviImport.get_datum_of_all_who_import(): + if not item in list_datum_of_all_who_data: + new_dates_reported_from_import.append(item) + return new_dates_reported_from_import + + def __update_data_incremental(self): + app.logger.info(" DiviServiceUpdate.__update_fact_tables_incremental [begin]") + app.logger.info("------------------------------------------------------------") + new_dates_reported_from_import = self.who_import_get_new_dates_as_array() + i = 0 + for my_date_reported in new_dates_reported_from_import: + app.logger.info(my_date_reported) + my_date = DiviDateReported.find_by_date_reported(my_date_reported) + if my_date is None: + myday = DiviDateReported.create_new_object_factory(my_date_reported) + db.session.add(myday) + db.session.commit() + my_date = DiviDateReported.get_by_date_reported(my_date_reported) + k = 0 + for result_item in DiviImport.get_for_one_day(my_date_reported): + if result_item.country_code == "": + my_country = DiviCountry.get_by_country(result_item.country) + else: + my_country = DiviCountry.get_by_country_code(result_item.country_code) + o = DiviData( + cases_new=int(result_item.new_cases), + cases_cumulative=int(result_item.cumulative_cases), + deaths_new=int(result_item.new_deaths), + deaths_cumulative=int(result_item.cumulative_deaths), + date_reported=my_date, + country=my_country + ) + db.session.add(o) + i += 1 + k += 1 + if i % 2000 == 0: + app.logger.info(" update DIVI incremental ... "+str(i)+" rows") + db.session.commit() + app.logger.info(" update DIVI incremental ... " + str(i) + " rows [" + str(my_date) + "] (" + str(k) + ")") + app.logger.info(" update DIVI incremental : "+str(i)+" rows total") + app.logger.info(" DiviServiceUpdate.__update_fact_tables_incremental [done]") + app.logger.info("------------------------------------------------------------") + return self + + def __update_data_initial(self): + app.logger.info(" DiviServiceUpdate.__update_fact_table_initial [begin]") + app.logger.info("------------------------------------------------------------") + DiviData.remove_all() + new_dates_reported_from_import = DiviImport.get_new_dates_as_array() + i = 0 + for my_date_reported in new_dates_reported_from_import: + my_date = DiviDateReported.find_by_date_reported(my_date_reported) + if my_date is None: + myday = DiviDateReported.create_new_object_factory(my_date_reported) + db.session.add(myday) + my_date = myday + for result_item in DiviImport.get_for_one_day(my_date_reported): + my_country = DiviCountry.find_by_country_code(result_item.country_code) + o = DiviData( + cases_new=int(result_item.new_cases), + cases_cumulative=int(result_item.cumulative_cases), + deaths_new=int(result_item.new_deaths), + deaths_cumulative=int(result_item.cumulative_deaths), + date_reported=my_date, + country=my_country + ) + db.session.add(o) + result_item.row_imported = True + db.session.add(result_item) + i += 1 + if i % 2000 == 0: + app.logger.info(" update WHO initial ... "+str(i)+" rows") + db.session.commit() + db.session.commit() + app.logger.info(" update WHO initial : "+str(i)+" total rows") + app.logger.info(" DiviServiceUpdate.__update_fact_table_initial [done]") + app.logger.info("------------------------------------------------------------") + return self + + def __update_dimension_tables(self): + self.__update_date_reported() + self.__update_region() + self.__update_country() + return self + + def update_dimension_tables_only(self): + app.logger.info(" update_dimension_tables_only [begin]") + app.logger.info("------------------------------------------------------------") + self.__update_dimension_tables() + app.logger.info(" update_dimension_tables_only [done]") + app.logger.info("------------------------------------------------------------") + return self + + def update_fact_table_incremental_only(self): + app.logger.info(" update_fact_tables_incremental_only [begin]") + app.logger.info("------------------------------------------------------------") + self.__update_data_incremental() + app.logger.info(" update_fact_tables_incremental_only [done]") + app.logger.info("------------------------------------------------------------") + return self + + def update_fact_table_initial_only(self): + app.logger.info(" update_fact_tables_initial_only [begin]") + app.logger.info("------------------------------------------------------------") + self.__update_data_initial() + app.logger.info(" update_fact_tables_initial_only [done]") + app.logger.info("------------------------------------------------------------") + return self + + def update_star_schema_incremental(self): + app.logger.info(" update_star_schema_incremental [begin]") + app.logger.info("------------------------------------------------------------") + self.__update_dimension_tables() + self.__update_data_incremental() + app.logger.info(" update_star_schema_incremental [done]") + app.logger.info("------------------------------------------------------------") + return self + + def update_star_schema_initial(self): + app.logger.info(" update_star_schema_initial [begin]") + app.logger.info("------------------------------------------------------------") + self.__update_dimension_tables() + self.__update_data_initial() + app.logger.info(" update_star_schema_initial [done]") + app.logger.info("------------------------------------------------------------") + return self + + #def update_dimension_tables_only(self): + #def update_fact_table_incremental_only(self): + #def update_fact_table_initial_only(self): + #def update_star_schema_incremental(self): + #def update_star_schema_initial(self): diff --git a/src/covid19/blueprints/intensivregister/divi_views.py b/src/covid19/blueprints/intensivregister/divi_views.py new file mode 100644 index 0000000000000000000000000000000000000000..d23cd990303bd7056bb7df92168d8dfd4b4b993f --- /dev/null +++ b/src/covid19/blueprints/intensivregister/divi_views.py @@ -0,0 +1,532 @@ +from flask import render_template, redirect, url_for, flash, Blueprint +from sqlalchemy.exc import OperationalError +from celery import states +from celery.utils.log import get_task_logger +from flask_admin.contrib.sqla import ModelView +from flask_login import login_required + +from database import app, admin, db +from covid19.blueprints.application.application_services import divi_service +from covid19.blueprints.application.application_workers import celery + +from covid19.blueprints.intensivregister.divi_model import DiviRegion, DiviDateReported, DiviCountry, DiviData +from covid19.blueprints.intensivregister.divi_model_import import DiviImport +from covid19.blueprints.application.application_model_transient import ApplicationPage + + +app_divi = Blueprint('divi', __name__, template_folder='templates', url_prefix='/divi') + +admin.add_view(ModelView(DiviImport, db.session, category="DIVI")) +admin.add_view(ModelView(DiviDateReported, db.session, category="DIVI")) +admin.add_view(ModelView(DiviRegion, db.session, category="DIVI")) +admin.add_view(ModelView(DiviCountry, db.session, category="DIVI")) +admin.add_view(ModelView(DiviData, db.session, category="DIVI")) + + +# --------------------------------------------------------------------------------------------------------------- +# Url Routes Frontend +# --------------------------------------------------------------------------------------------------------------- + + +@app_divi.route('/info') +def url_divi_info(): + page_info = ApplicationPage('WHO', "Info") + return render_template( + 'divi/divi_info.html', + page_info=page_info) + + +@app_divi.route('/tasks') +@login_required +def url_divi_tasks(): + page_info = ApplicationPage('WHO', "Tasks") + return render_template( + 'divi/divi_tasks.html', + page_info=page_info) + + +@app_divi.route('/imported/page/<int:page>') +@app_divi.route('/imported') +@login_required +def url_divi_imported(page=1): + page_info = ApplicationPage('WHO', "Last Import") + try: + page_data = DiviImport.get_all_as_page(page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/divi_imported.html', + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/all/page/<int:page>') +@app_divi.route('/date_reported/all') +def url_divi_date_reported_all(page: int = 1): + page_info = ApplicationPage('WHO', "Date Reported", "All") + try: + page_data = DiviDateReported.get_all_as_page(page) + except OperationalError: + flash("No regions in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_all.html', + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/<int:date_reported_id>/page/<int:page>') +@app_divi.route('/date_reported/<int:date_reported_id>') +def url_divi_date_reported(date_reported_id: int, page: int = 1): + date_reported = DiviDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = DiviData.get_data_for_day(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_one.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/<int:date_reported_id>/cases_new/page/<int:page>') +@app_divi.route('/date_reported/<int:date_reported_id>/cases_new') +def url_divi_date_reported_cases_new(date_reported_id: int, page: int = 1): + date_reported = DiviDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = DiviData.get_data_for_day_order_by_cases_new(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_one_cases_new.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/<int:date_reported_id>/cases_cumulative/page/<int:page>') +@app_divi.route('/date_reported/<int:date_reported_id>/cases_cumulative') +def url_divi_date_reported_cases_cumulative(date_reported_id: int, page: int = 1): + date_reported = DiviDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = DiviData.get_data_for_day_order_by_cases_cumulative(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_one_cases_cumulative.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/<int:date_reported_id>/deaths_new/page/<int:page>') +@app_divi.route('/date_reported/<int:date_reported_id>/deaths_new') +def url_divi_date_reported_deaths_new(date_reported_id: int, page: int = 1): + date_reported = DiviDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = DiviData.get_data_for_day_order_by_deaths_new(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_one_deaths_new.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/date_reported/<int:date_reported_id>/deaths_cumulative/page/<int:page>') +@app_divi.route('/date_reported/<int:date_reported_id>/deaths_cumulative') +def url_divi_date_reported_deaths_cumulative(date_reported_id: int, page: int = 1): + date_reported = DiviDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = DiviData.get_data_for_day_order_by_deaths_cumulative(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'divi/date_reported/divi_date_reported_one_deaths_cumulative.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/region/all/page/<int:page>') +@app_divi.route('/region/all') +def url_divi_region_all(page: int = 1): + page_info = ApplicationPage('WHO', "Region", "All") + try: + page_data = DiviRegion.get_all_as_page(page) + except OperationalError: + flash("No regions in the database.") + page_data = None + return render_template( + 'divi/region/divi_region_all.html', + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/region/<int:region_id>/page/<int:page>') +@app_divi.route('/region/<int:region_id>') +def url_divi_region(region_id: int, page: int = 1): + who_region = None + page_info = ApplicationPage("Countries", "WHO Region") + try: + who_region = DiviRegion.get_by_id(region_id) + page_data = DiviCountry.get_who_countries_for_region(who_region, page) + page_info.title = who_region.region + page_info.subtitle = "WHO Region" + page_info.subtitle_info = "Countries of WHO Region " + who_region.region + except OperationalError: + flash("No countries of that region in the database.") + page_data = None + return render_template( + 'divi/region/divi_region_one.html', + who_region=who_region, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/all/page/<int:page>') +@app_divi.route('/country/all') +def url_divi_country_all(page: int = 1): + page_info = ApplicationPage('WHO', "Countries", "All") + try: + page_data = DiviCountry.get_all_as_page(page) + except OperationalError: + flash("No regions in the database.") + page_data = None + return render_template( + 'divi/country/divi_country_all.html', + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/<int:country_id>/page/<int:page>') +@app_divi.route('/country/<int:country_id>') +def url_divi_country(country_id: int, page: int = 1): + who_country = DiviCountry.get_by_id(country_id) + page_data = DiviData.get_data_for_country(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'divi/country/divi_country_one.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/<int:country_id>/cases_new/page/<int:page>') +@app_divi.route('/country/<int:country_id>/cases_new') +def url_divi_country_cases_new(country_id: int, page: int = 1): + who_country = DiviCountry.get_by_id(country_id) + page_data = DiviData.get_data_for_country_order_by_cases_new(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'divi/country/divi_country_one_cases_new.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/<int:country_id>/cases_cumulative/page/<int:page>') +@app_divi.route('/country/<int:country_id>/cases_cumulative') +def url_divi_country_cases_cumulative(country_id: int, page: int = 1): + who_country = DiviCountry.get_by_id(country_id) + page_data = DiviData.get_data_for_country_order_by_cases_cumulative(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'divi/country/divi_country_one_cases_cumulative.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/<int:country_id>/deaths_new/page/<int:page>') +@app_divi.route('/country/<int:country_id>/deaths_new') +def url_divi_country_deaths_new(country_id: int, page: int = 1): + who_country = DiviCountry.get_by_id(country_id) + page_data = DiviData.get_data_for_country_order_by_deaths_new(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'divi/country/divi_country_one_deaths_new.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/country/<int:country_id>/deaths_cumulative/page/<int:page>') +@app_divi.route('/country/<int:country_id>/deaths_cumulative') +def url_divi_country_deaths_cumulative(country_id: int, page: int = 1): + who_country = DiviCountry.get_by_id(country_id) + page_data = DiviData.get_data_for_country_order_by_deaths_cumulative(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'divi/country/divi_country_one_deaths_cumulative.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/germany/page/<int:page>') +@app_divi.route('/germany') +def url_divi_germany(page: int = 1): + page_info = ApplicationPage('WHO', "Germany") + who_country_germany = DiviCountry.get_germany() + if who_country_germany is None: + flash('country: Germany not found in Database', category='error') + return redirect(url_for('who.url_divi_tasks')) + page_data = DiviData.get_data_for_country(who_country_germany, page) + return render_template( + 'divi/country/divi_country_germany.html', + who_country=who_country_germany, + page_data=page_data, + page_info=page_info) + + +@app_divi.route('/mytest') +def url_divi_mytest(): + flash("url_divi_mytest - START: DiviImport.countries()") + app.logger.info("url_divi_mytest - START: DiviImport.countries()") + i = 0 + for c in DiviImport.countries(): + i += 1 + line = " | " + str(i) + " | " + c.countries.country_code + " | " + c.countries.country + " | " + c.countries.who_region + " | " + app.logger.info(line) + flash("url_divi_mytest - DONE: DiviImport.countries()") + app.logger.info("url_divi_mytest - DONE: DiviImport.countries()") + flash("url_divi_mytest - START: DiviImport.get_new_dates_as_array()") + app.logger.info("url_divi_mytest - START: DiviImport.get_new_dates_as_array()") + i = 0 + for date_reported in DiviImport.get_new_dates_as_array(): + i += 1 + line = " | " + str(i) + " | " + date_reported + " | " + app.logger.info(line) + joungest_datum = DiviDateReported.get_joungest_datum() + app.logger.info(joungest_datum) + i = 0 + for who_data in DiviData.get_data_for_one_day(joungest_datum): + i += 1 + line = " | " + str(i) + " | " + str(who_data.date_reported) + " | " + who_data.country.country + " | " + app.logger.info(line) + flash("url_divi_mytest - DONE: DiviImport.get_new_dates_as_array()") + app.logger.info("url_divi_mytest - DONE: DiviImport.get_new_dates_as_array()") + return redirect(url_for('who.url_divi_tasks')) + +# ---------------------------------------------------------------------------------------------------------------- +# Celery TASKS +# ---------------------------------------------------------------------------------------------------------------- + + +@celery.task(bind=True) +def task_divi_download_only(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_download_only [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_download_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_download_only)" + return result + + +@celery.task(bind=True) +def task_divi_import_only(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_import_only [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_import_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_import_only)" + return result + + +@celery.task(bind=True) +def task_divi_update_dimension_tables_only(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_update_dimension_tables_only [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_update_dimension_tables_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_update_dimension_tables_only)" + return result + + +@celery.task(bind=True) +def task_divi_update_fact_table_incremental_only(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_update_fact_table_incremental_only [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_update_fact_table_incremental_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_update_dimension_tables_only)" + return result + + +@celery.task(bind=True) +def task_divi_update_fact_table_initial_only(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_update_fact_table_initial_only [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_update_fact_table_initial_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_update_fact_table_initial_only)" + return result + + +@celery.task(bind=True) +def task_divi_update_star_schema_incremental(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_update_star_schema_incremental [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_update_star_schema_incremental() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_update_star_schema_incremental)" + return result + + +@celery.task(bind=True) +def task_divi_update_star_schema_initial(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_divi_update_star_schema_initial [OK] ") + logger.info("------------------------------------------------------------") + divi_service.run_update_star_schema_initial() + self.update_state(state=states.SUCCESS) + result = "OK (task_divi_update_star_schema_incremental)" + return result + +# ---------------------------------------------------------------------------------------------------------------- +# URL Routes for Celery TASKS +# ---------------------------------------------------------------------------------------------------------------- + + +@app_divi.route('/task/download/only') +@login_required +def url_task_divi_download_only(): + app.logger.info("url_divi_task_download_only [start]") + divi_service.run_download_only() + flash("divi_service.run_download_only ok") + app.logger.info("url_divi_task_download_only [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/import/only') +@login_required +def url_task_divi_import_only(): + app.logger.info("url_divi_update_run [start]") + task_divi_import_only.apply_async() + flash("divi_service.run_update started") + flash(message="long running background task started", category="warning") + app.logger.info("url_divi_update_run [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/update/dimension-tables/only') +@login_required +def url_task_divi_update_dimension_tables_only(): + app.logger.info("url_task_divi_update_dimension_tables_only [start]") + task_divi_update_dimension_tables_only.apply_async() + flash("task_divi_update_dimension_tables_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_divi_update_dimension_tables_only [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/update/fact-table/incremental/only') +@login_required +def url_task_divi_update_fact_table_incremental_only(): + app.logger.info("url_task_divi_update_fact_table_incremental_only [start]") + task_divi_update_fact_table_incremental_only.apply_async() + flash("task_divi_update_fact_table_incremental_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_divi_update_fact_table_incremental_only [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/update/fact-table/initial/only') +@login_required +def url_task_divi_update_fact_table_initial_only(): + app.logger.info("url_task_divi_update_fact_table_initial_only [start]") + task_divi_update_fact_table_initial_only.apply_async() + flash("task_divi_update_fact_table_initial_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_divi_task_update_full [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/update/star_schema/initial') +@login_required +def url_task_divi_update_star_schema_initial(): + app.logger.info("url_divi_task_update_full [start]") + divi_service.run_download_only() + flash("divi_service.service_download.download_file ok") + task_divi_update_star_schema_initial.apply_async() + flash("task_divi_update_star_schema_initial started") + flash(message="long running background task started", category="warning") + app.logger.info("url_divi_task_update_full [done]") + return redirect(url_for('who.url_divi_tasks')) + + +@app_divi.route('/task/update/star_schema/incremental') +@login_required +def url_task_divi_update_star_schema_incremental(): + app.logger.info("url_task_divi_update_star_schema_incremental [start]") + divi_service.run_download_only() + flash("divi_service.service_download.download_file ok") + task_divi_update_star_schema_incremental.apply_async() + flash("task_divi_run_update_full started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_divi_update_star_schema_incremental [done]") + return redirect(url_for('who.url_divi_tasks')) diff --git a/src/covid19/blueprints/intensivregister/templates/__init__.py b/src/covid19/blueprints/intensivregister/templates/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all.html new file mode 100644 index 0000000000000000000000000000000000000000..da3c31d72d0481d16de5409022113b1f148ca06e --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all.html @@ -0,0 +1,33 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_all_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_all_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_all_pagination.html' %} + </div> + </div> + </div> + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..469047e8abf29b56d3caf686ed6b5ac01879ce85 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_pagination.html @@ -0,0 +1,35 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_country_all', page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_country_all', page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_country_all', page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} + diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_table.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_table.html new file mode 100644 index 0000000000000000000000000000000000000000..29c2c8c55568d72950e35a1232b81e050172ec6f --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_all_table.html @@ -0,0 +1,49 @@ + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + <tr> + <th scope="col"> + country + </th> + <th scope="col"> + country code + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_region_all') }}">region</a> + </th> + </tr> + </thead> + <tbody> + {% for who_country in page_data.items %} + <tr> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_country.id) }}"> + {{ who_country.country }} + </a> + </td> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_country.id) }}"> + {{ who_country.country_code }} + </a> + </td> + <th> + <a href="{{ url_for('who.url_who_region', region_id=who_country.region.id) }}"> + {{ who_country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + <tfoot class="table-secondary"> + <tr> + <th scope="col"> + country + </th> + <th scope="col"> + country code + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_region_all') }}">region</a> + </th> + </tr> + </tfoot> + </table> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany.html new file mode 100644 index 0000000000000000000000000000000000000000..cd4675faad9c64d74e8822f753415844f80a501a --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany.html @@ -0,0 +1,33 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_germany_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_germany_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..3aaba2d4fe7668235622815621920e2926013b1e --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_germany_pagination.html @@ -0,0 +1,40 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_germany', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_germany', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_germany', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one.html new file mode 100644 index 0000000000000000000000000000000000000000..7f61469fe8597dc6f9005c58247e8160448000b0 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + <div class="col"> + {% include 'who/country/who_country_one_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..5aae35beb7ca944108a520b7800393c22aa14aca --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative.html @@ -0,0 +1,33 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_cases_cumulative_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_cases_cumulative_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..9853ccedc91489e33fe7bef0c14509bfc8c6b579 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_cumulative_pagination.html @@ -0,0 +1,40 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_cumulative', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_cumulative', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_cumulative', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new.html new file mode 100644 index 0000000000000000000000000000000000000000..a522b64cdceb012b4ba9b9fb2c194ea7ee2500c5 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new.html @@ -0,0 +1,34 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_cases_new_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_cases_new_pagination.html' %} + </div> + </div> + </div> + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..fce53cfa7f626930a60ddc67ea12cb65fd959767 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_cases_new_pagination.html @@ -0,0 +1,40 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_new', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_new', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_cases_new', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..d55e49fc8fbfb8c331de4c776f9d878148a6aa6b --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative.html @@ -0,0 +1,34 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_deaths_cumulative_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_deaths_cumulative_pagination.html' %} + </div> + </div> + </div> + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..cce38e1b35985f1c07585b49da5aa8d09bef561b --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_cumulative_pagination.html @@ -0,0 +1,40 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_cumulative', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_cumulative', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_cumulative', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new.html new file mode 100644 index 0000000000000000000000000000000000000000..6a771b79bc54481fad5b95e556c13d23ddd0ba36 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new.html @@ -0,0 +1,59 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_one_table.html' %} + </div> + </div> + </div> + +{% endblock %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..9a88e6709f638e8d5784ee79b6679e48643d94a2 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_deaths_new_pagination.html @@ -0,0 +1,41 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country_deaths_new', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..c2561c3ef27f1618978e32f96bf3790e9e9a509e --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_pagination.html @@ -0,0 +1,40 @@ + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country', country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'who.url_who_country', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_table.html b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_table.html new file mode 100644 index 0000000000000000000000000000000000000000..f8537ede976f089bbf036965dd1935cb621933dc --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/country/who_country_one_table.html @@ -0,0 +1,84 @@ + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + <tr> + <th scope="col"> + <a href="{{ url_for('who.url_who_date_reported_all') }}"> + date reported + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_deaths_new',country_id=who_country.id) }}"> + deaths new + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_cases_new',country_id=who_country.id) }}"> + cases new + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_deaths_cumulative',country_id=who_country.id) }}"> + deaths cumulative + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_cases_cumulative',country_id=who_country.id) }}"> + cases cumulative + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_all') }}"> + country code + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_all') }}"> + country + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_region_all') }}"> + region + </a> + </th> + </tr> + </thead> + <tbody> + {% for who_global_data in page_data.items %} + <tr> + <th> + <a href="{{ url_for('who.url_who_date_reported',date_reported_id=who_global_data.date_reported.id) }}"> + {{ who_global_data.date_reported }} + </a> + </th> + <td> + {{ who_global_data.deaths_new }} + </td> + <td> + {{ who_global_data.cases_new }} + </td> + <td> + {{ who_global_data.deaths_cumulative }} + </td> + <td> + {{ who_global_data.cases_cumulative }} + </td> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_global_data.country.id) }}"> + {{ who_global_data.country.country_code }} + </a> + </td> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_global_data.country.id) }}"> + {{ who_global_data.country.country }} + </a> + </td> + <th> + <a href="{{ url_for('who.url_who_region', region_id=who_global_data.country.region.id) }}"> + {{ who_global_data.country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all.html new file mode 100644 index 0000000000000000000000000000000000000000..eea1d5dab6331468a984df2f3fc2fe962f0f3f34 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_all_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_all_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_all_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..3434879171248384b5af560384ba84e538558fce --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_pagination.html @@ -0,0 +1,34 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_all', page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_all', page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_all', page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_table.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_table.html new file mode 100644 index 0000000000000000000000000000000000000000..ef541983181cfca3c2f92fcf3d2271dcf7659647 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_all_table.html @@ -0,0 +1,39 @@ + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + <tr> + <th scope="col" class="text-right">day of week</th> + <th scope="col" class="text-left">date reported</th> + <th scope="col" class="text-right">week of year</th> + <th scope="col" class="text-left">year</th> + </tr> + </thead> + <tbody> + {% for who_date_reported in page_data.items %} + <tr> + <td class="text-right"> + {{ who_date_reported.get_name_for_weekday() }} + </td> + <td class="text-left"> + <a href="/who/date_reported/{{ who_date_reported.id }}"> + {{ who_date_reported }} + </a> + </td> + <td class="text-right"> + {{ who_date_reported.week_of_year }} + </td> + <td class="text-left"> + {{ who_date_reported.year }} + </td> + </tr> + {% endfor %} + </tbody> + <tfoot class="table-secondary"> + <tr> + <th scope="col" class="text-right">day of week</th> + <th scope="col" class="text-left">date reported</th> + <th scope="col" class="text-right">week of year</th> + <th scope="col" class="text-left">year</th> + </tr> + </tfoot> + </table> + diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one.html new file mode 100644 index 0000000000000000000000000000000000000000..fb852908da57023a907d05d68bc08d75f8bd3bfa --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one.html @@ -0,0 +1,33 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + </div> + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..2e6562a57a27c4cccce811027fea0fc595b738f3 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative.html @@ -0,0 +1,31 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..3b6188546206e22f6a94ef7de8ed1d7649d513a2 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_cumulative_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new.html new file mode 100644 index 0000000000000000000000000000000000000000..fb852908da57023a907d05d68bc08d75f8bd3bfa --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new.html @@ -0,0 +1,33 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + </div> + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..dc0782434b92c4992f1d9620ad854811629cad6a --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_cases_new_pagination.html @@ -0,0 +1,39 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..6cade560341b221034de178f547b65c38538e911 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..3b6188546206e22f6a94ef7de8ed1d7649d513a2 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_cumulative_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_new.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_new.html new file mode 100644 index 0000000000000000000000000000000000000000..c61e0d1972b4df5e5cc5ef3b37a7458fb522ffbf --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_deaths_new.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/date_reported/who_date_reported_one_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..7938fbcd1c4430f3657c078d2a323fa4e7d7cdaf --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_date_reported', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_table.html b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_table.html new file mode 100644 index 0000000000000000000000000000000000000000..5dd91bb5f923b421ff7b1464797bd1182ccac7e0 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/date_reported/who_date_reported_one_table.html @@ -0,0 +1,84 @@ + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + <tr> + <th scope="col"> + <a href="{{ url_for('who.url_who_date_reported_all') }}"> + date reported + </a> + </th> + <th scope="col"> who. + <a href="{{ url_for('who.url_who_date_reported_deaths_new', date_reported_id=who_date_reported.id) }}"> + deaths new + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_date_reported_cases_new', date_reported_id=who_date_reported.id) }}"> + cases new + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_date_reported_deaths_cumulative', date_reported_id=who_date_reported.id) }}"> + deaths cumulative + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_date_reported_cases_cumulative', date_reported_id=who_date_reported.id) }}"> + cases cumulative + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_all') }}"> + country code + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_country_all') }}"> + country + </a> + </th> + <th scope="col"> + <a href="{{ url_for('who.url_who_region_all') }}"> + region + </a> + </th> + </tr> + </thead> + <tbody> + {% for who_global_data in page_data.items %} + <tr> + <th> + <a href="{{ url_for('who.url_who_date_reported', date_reported_id=who_global_data.date_reported.id) }}"> + {{ who_global_data.date_reported }} + </a> + </th> + <td> + {{ who_global_data.deaths_new }} + </td> + <td> + {{ who_global_data.cases_new }} + </td> + <td> + {{ who_global_data.deaths_cumulative }} + </td> + <td> + {{ who_global_data.cases_cumulative }} + </td> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_global_data.country.id ) }}"> + {{ who_global_data.country.country_code }} + </a> + </td> + <td> + <a href="{{ url_for('who.url_who_country', country_id=who_global_data.country.id) }}"> + {{ who_global_data.country.country }} + </a> + </td> + <th> + <a href="{{ url_for('who.url_who_region', region_id=who_global_data.country.region.id) }}"> + {{ who_global_data.country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..d0d56482bb784e9352439d0d1b38a76d3bfd4bd0 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('who.url_who_imported', page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('who.url_who_imported', page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('who.url_who_imported', page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_table.html b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_table.html new file mode 100644 index 0000000000000000000000000000000000000000..941f320b750d00038bc84af70bef5e4c5db83d5f --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_imported_table.html @@ -0,0 +1,28 @@ + <table class="table table-hover table-striped table-dark"> + <thead> + <tr> + <th scope="col">date reported</th> + <th scope="col">country</th> + <th scope="col">country code</th> + <th scope="col">who region</th> + <th scope="col">new cases</th> + <th scope="col">cumulative cases</th> + <th scope="col">new deaths</th> + <th scope="col">cumulative deaths</th> + </tr> + </thead> + <tbody> + {% for who_global_data_import in page_data.items %} + <tr> + <td>{{ who_global_data_import.date_reported }}</td> + <td>{{ who_global_data_import.country }}</td> + <td>{{ who_global_data_import.country_code }}</td> + <td>{{ who_global_data_import.who_region }}</td> + <td>{{ who_global_data_import.new_cases }}</td> + <td>{{ who_global_data_import.cumulative_cases }}</td> + <td>{{ who_global_data_import.new_deaths }}</td> + <td>{{ who_global_data_import.cumulative_deaths }}</td> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_table_global_data.html b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_table_global_data.html new file mode 100644 index 0000000000000000000000000000000000000000..90049ac244f2bee17b01e80c0e4f15a1aa10aff9 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/fragments/fragment_who_table_global_data.html @@ -0,0 +1,68 @@ + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + <tr> + <th scope="col"> + <a href="{{ url_for( 'who.url_who_date_reported_all') }}"> + date reported + </a> + </th> + <th scope="col"> + deaths new + </th> + <th scope="col"> + cases new + </th> + <th scope="col"> + deaths cumulative + </th> + <th scope="col"> + cases cumulative + </th> + <th scope="col"> + <a href="{{ url_for( 'who.url_who_country_all') }}"> + country code + </a> + </th> + <th scope="col"> + <a href="{{ url_for( 'who.url_who_country_all') }}"> + country + </a> + </th> + <th scope="col"> + <a href="{{ url_for( 'who.url_who_region_all') }}"> + region + </a> + </th> + </tr> + </thead> + <tbody> + {% for who_global_data in page_data.items %} + <tr> + <th> + <a href="/who/date_reported/{{ who_global_data.date_reported.id }}"> + {{ who_global_data.date_reported }} + </a> + </th> + <td>{{ who_global_data.deaths_new }}</td> + <td>{{ who_global_data.cases_new }}</td> + <td>{{ who_global_data.deaths_cumulative }}</td> + <td>{{ who_global_data.cases_cumulative }}</td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country_code }} + </a> + </td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country }} + </a> + </td> + <th> + <a href="/who/region/{{ who_global_data.country.region.id }}"> + {{ who_global_data.country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navbar_dropdown.html b/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navbar_dropdown.html new file mode 100644 index 0000000000000000000000000000000000000000..2c2e5a9df4da1ab5a5a18de69361cec947ad163c --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navbar_dropdown.html @@ -0,0 +1,63 @@ + <li class="dropdown"> + <a class="dropdown-toggle nav-link" data-toggle="dropdown" href="javascript:void(0)"> + WHO<i class="glyphicon glyphicon-chevron-down small"></i> + </a> + <ul class="dropdown-menu"> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_date_reported_all') }}"> + WHO + </a> + </li> + <li> + <div class="dropdown-divider"></div> + </li> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_germany') }}"> + WHO Germany + </a> + </li> + <li> + <div class="dropdown-divider"></div> + </li> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_region_all') }}"> + WHO Regions + </a> + </li> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_date_reported_all') }}"> + WHO Date Reported + </a> + </li> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_country_all') }}"> + WHO Countries + </a> + </li> + <li> + <div class="dropdown-divider"></div> + </li> + {% if current_user.is_authenticated %} + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_imported') }}"> + WHO imported + </a> + </li> + {% endif %} + <li> + <div class="dropdown-divider"></div> + </li> + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_info') }}"> + WHO Info + </a> + </li> + {% if current_user.is_authenticated %} + <li> + <a class="dropdown-item" href="{{ url_for( 'who.url_who_tasks') }}"> + WHO Tasks + </a> + </li> + {% endif %} + </ul> + </li> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navtabs.html b/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navtabs.html new file mode 100644 index 0000000000000000000000000000000000000000..032b51dc9f878a8676f2532346bc6777e51662e3 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/navigation/who_navtabs.html @@ -0,0 +1,48 @@ + + + <div class="container"> + <div class="row-cols-1"> + <nav> + <ul class="nav nav-tabs"> + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_info') }}">WHO Info</a> + </li> + {% if current_user.is_authenticated %} + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_tasks') }}">WHO tasks</a> + </li> + {% endif %} + {% if current_user.is_authenticated %} + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who_test.url_who_test_tests') }}">WHO Tests</a> + </li> + {% endif %} + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_date_reported_all') }}">WHO Date Reported</a> + </li> + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_germany') }}">WHO Germany</a> + </li> + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_region_all') }}">WHO Regions</a> + </li> + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_country_all') }}">WHO Countries</a> + </li> + {% if current_user.is_authenticated %} + <li class="nav-item"> + <a class="nav-link" + href="{{ url_for( 'who.url_who_imported') }}">WHO imported</a> + </li> + {% endif %} + </ul> + </nav> + </div> + </div> \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all.html b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all.html new file mode 100644 index 0000000000000000000000000000000000000000..12960224fc8e1134a925f295a3b040d3e3bf3c5d --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/region/who_region_all_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/region/who_region_all_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/region/who_region_all_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..35f878b3fcfec2a0363cad44ab96a4819b44eb20 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_pagination.html @@ -0,0 +1,41 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + <!-- previous page --> + {% if page_data.has_prev %} + <li> + <a href="{{ url_for('who.url_who_region_all', page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li> + <a href="{{ url_for('who.url_who_region_all', page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="active"> + <a href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li> + <a href="{{ url_for('who.url_who_region_all', page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_table.html b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_table.html new file mode 100644 index 0000000000000000000000000000000000000000..a62785a58196e057fc16ce2937251a7126b4f2c4 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_all_table.html @@ -0,0 +1,19 @@ + + <table class="table table-hover table-striped table-dark"> + <thead> + <tr> + <th scope="col">who_region</th> + </tr> + </thead> + <tbody> + {% for who_region in page_data.items %} + <tr> + <td> + <a href="/who/region/{{ who_region.id }}"> + {{ who_region.region }} + </a> + </td> + </tr> + {% endfor %} + </tbody> + </table> diff --git a/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one.html b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one.html new file mode 100644 index 0000000000000000000000000000000000000000..e273103351b75ac5ba0d54a70ffb0efe954eb0c4 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one.html @@ -0,0 +1,35 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/region/who_region_one_pagination.html' %} + </div> + </div> + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/country/who_country_all_table.html' %} + </div> + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/region/who_region_one_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one_pagination.html b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..ad18ea25e07c59a7a33f3afe2f8177ed4de7d4b8 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/region/who_region_one_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_region', + region_id=who_region.id , page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_region', + region_id=who_region.id ,page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('who.url_who_region', + region_id=who_region.id , page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/intensivregister/templates/who/who_imported.html b/src/covid19/blueprints/intensivregister/templates/who/who_imported.html new file mode 100644 index 0000000000000000000000000000000000000000..d12fed01d11e780fb0ef5fb7a5ffea531913d2c5 --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/who_imported.html @@ -0,0 +1,32 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'who/fragments/fragment_who_imported_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/fragments/fragment_who_imported_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'who/fragments/fragment_who_imported_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + +{% endblock %} + + + diff --git a/src/covid19/blueprints/intensivregister/templates/who/who_info.html b/src/covid19/blueprints/intensivregister/templates/who/who_info.html new file mode 100644 index 0000000000000000000000000000000000000000..43bb0444dd4b903d25ba2b6c07e7501283266e0e --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/who_info.html @@ -0,0 +1,47 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + <div class="card"> + <div class="card-body"> + <div class="card-title"> + Dashboard + </div> + <div class="card-text"> + WHO Coronavirus Disease (COVID-19) + </div> + <div class="card-text"> + <a class="btn btn-primary" href="https://covid19.who.int/">https://covid19.who.int</a> + </div> + </div> + </div> + </div> + <div class="col"> + <div class="card"> + <div class="card-body"> + <div class="card-title"> + Pandemic + </div> + <div class="card-text"> + WHO Coronavirus Disease (COVID-19) + </div> + <div class="card-text"> + <a class="btn btn-primary" href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019"> + novel-coronavirus-2019 + </a> + </div> + </div> + </div> + </div> + </div> + </div> +{% endblock %} + + + + diff --git a/src/covid19/blueprints/intensivregister/templates/who/who_tasks.html b/src/covid19/blueprints/intensivregister/templates/who/who_tasks.html new file mode 100644 index 0000000000000000000000000000000000000000..51281f271f0c5ec2be13e31e5afc593922e060ff --- /dev/null +++ b/src/covid19/blueprints/intensivregister/templates/who/who_tasks.html @@ -0,0 +1,49 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'who/navigation/who_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + <div class="btn-group-vertical" role="group" aria-label="Views"> + <a class="btn btn-primary btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_update_star_schema_initial') }}" + role="button">WHO :: Task :: update :: star_schema :: initial</a> + <a class="btn btn-primary btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_update_star_schema_incremental') }}" + role="button">WHO :: Task :: update :: star_schema :: incremental</a> + </div> + </div> + <div class="col"> + <div class="btn-group-vertical" role="group" aria-label="Views"> + <a class="btn btn-success btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_download_only') }}" + role="button">WHO :: Task :: download :: only</a> + <a class="btn btn-info btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_import_only') }}" + role="button">WHO :: Task :: import :: only</a> + <a class="btn btn-warning btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_update_dimension_tables_only') }}" + role="button">WHO :: Task :: update :: dimension-tables : only</a> + <a class="btn btn-danger btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_update_fact_table_incremental_only') }}" + role="button">WHO :: Task :: update :: fact-table :: only :: incremental</a> + <a class="btn btn-secondary btn-lg btn-block text-left" + href="{{ url_for( 'who.url_task_who_update_fact_table_initial_only') }}" + role="button">WHO :: Task :: update :: fact-table :: only :: initial</a> + </div> + </div> + </div> + </div> +{% endblock %} + + + +{% block footer_container %} + +{% endblock %} + + +