diff --git a/src/covid19/blueprints/application/application_model.py b/src/covid19/blueprints/application/application_model.py index 44a2f0250b136723be2256447d7e93316cbdf41e..7af9a69eb40f267c29a863971f134d42eb1f2bdd 100644 --- a/src/covid19/blueprints/application/application_model.py +++ b/src/covid19/blueprints/application/application_model.py @@ -83,12 +83,12 @@ class ApplicationDateReported(db.Model): @classmethod def create_new_object_factory(cls, my_date_rep: str): (my_year, my_month, my_day) = cls.get_datum_parts(my_date_rep) - date_reported = cls.get_datum_as_str(my_year, my_month, my_day) + date_reported_import_str = cls.get_datum_as_str(my_year, my_month, my_day) my_datum = cls.get_datum(my_year, my_month, my_day) (my_iso_year, week_number, weekday) = my_datum.isocalendar() my_year_week = cls.my_year_week(my_iso_year, week_number) return ApplicationDateReported( - date_reported=date_reported, + date_reported_import_str=date_reported_import_str, datum=my_datum, year=my_datum.year, month=my_datum.month, @@ -108,7 +108,7 @@ class ApplicationDateReported(db.Model): @classmethod def get_all_as_page(cls, page: int): return db.session.query(cls)\ - .order_by(cls.date_reported.desc())\ + .order_by(cls.date_reported_import_str.desc())\ .paginate(page, per_page=ITEMS_PER_PAGE) @classmethod @@ -119,7 +119,7 @@ class ApplicationDateReported(db.Model): def get_all_as_dict(cls): dates_reported = {} for my_date_reported in cls.get_all(): - dates_reported[my_date_reported.date_reported] = my_date_reported + dates_reported[my_date_reported.date_reported_import_str] = my_date_reported return dates_reported @classmethod @@ -137,13 +137,13 @@ class ApplicationDateReported(db.Model): @classmethod def get_by_date_reported(cls, p_date_reported: str): return db.session.query(cls)\ - .filter(cls.date_reported == p_date_reported)\ + .filter(cls.date_reported_import_str == p_date_reported)\ .one() @classmethod def find_by_date_reported(cls, p_date_reported: str): return db.session.query(cls)\ - .filter(cls.date_reported == p_date_reported)\ + .filter(cls.date_reported_import_str == p_date_reported)\ .one_or_none() @classmethod @@ -161,7 +161,7 @@ class ApplicationDateReported(db.Model): @classmethod def get_joungest_datum(cls): return db.session.query(cls)\ - .order_by(cls.date_reported.desc())\ + .order_by(cls.date_reported_import_str.desc())\ .first() class ApplicationRegion(db.Model): diff --git a/src/covid19/blueprints/who/who_model.py b/src/covid19/blueprints/who/who_model.py index 7a52374f7fe2e8e348ed06a410a5f8f90e7db46b..6ed9b066b389d6e04b9995fe2f283c6fb556c4e8 100644 --- a/src/covid19/blueprints/who/who_model.py +++ b/src/covid19/blueprints/who/who_model.py @@ -23,22 +23,6 @@ class WhoDateReported(ApplicationDateReported): day_of_week = db.Column(db.Integer, nullable=False) week_of_year = db.Column(db.Integer, nullable=False) - ### - # select - # distinct - # who_datereported.date_reported - # from - # who - # left join - # who_datereported - # on - # who.date_reported_id=who_datereported.id - # group by - # who_datereported.date_reported - # order by - # who_datereported.date_reported desc - ### - @classmethod def create_new_object_factory(cls, my_date_rep): my_datum = date.fromisoformat(my_date_rep) @@ -361,7 +345,13 @@ class WhoData(db.Model): @classmethod def get_datum_of_all_who_data(cls): - return db.session.query(cls).options(subqueryload("date_reported").load_only("date_reported_import_str")) + 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_datum_of_all_who_data2(cls): diff --git a/src/covid19/blueprints/who/who_model_import.py b/src/covid19/blueprints/who/who_model_import.py index f220dd5e5df4495265de4b25a7e3b482ea8591cf..41739210c880d3787dbb756e22865c1e2ed0bb3c 100644 --- a/src/covid19/blueprints/who/who_model_import.py +++ b/src/covid19/blueprints/who/who_model_import.py @@ -89,7 +89,7 @@ class WhoImport(db.Model): not in ( select distinct - who_datereported.date_reported + who_datereported.date_reported_import_str from who left join @@ -97,9 +97,9 @@ class WhoImport(db.Model): on who.date_reported_id=who_datereported.id group by - who_datereported.date_reported + who_datereported.date_reported_import_str order by - who_datereported.date_reported desc + who_datereported.date_reported_import_str desc ) group by application__import__who.date_reported @@ -125,7 +125,7 @@ class WhoImport(db.Model): not in ( select distinct - who_datereported.date_reported + who_datereported.date_reported_import_str from who left join @@ -133,9 +133,9 @@ class WhoImport(db.Model): on who.date_reported_id=who_datereported.id group by - who_datereported.date_reported + who_datereported.date_reported_import_str order by - who_datereported.date_reported desc + who_datereported.date_reported_import_str desc ) group by application__import__who.date_reported diff --git a/src/covid19/blueprints/who/who_views.py b/src/covid19/blueprints/who/who_views.py index 5842d14920461fbaad11da3a7c16e4576976f13b..bc30cef10b8c65a742608ffa0293106ec50b21a3 100644 --- a/src/covid19/blueprints/who/who_views.py +++ b/src/covid19/blueprints/who/who_views.py @@ -367,6 +367,7 @@ def task_who_download_only(self): who_service.run_download_only() self.update_state(state=states.SUCCESS) result = "OK (task_who_download_only)" + flash(message="Finished: task_who_download_only [OK]", category="warning") return result @@ -380,6 +381,7 @@ def task_who_import_only(self): who_service.run_import_only() self.update_state(state=states.SUCCESS) result = "OK (task_who_import_only)" + flash(message="Finished: task_who_import_only [OK]", category="warning") return result @@ -393,6 +395,7 @@ def task_who_update_dimension_tables_only(self): who_service.run_update_dimension_tables_only() self.update_state(state=states.SUCCESS) result = "OK (task_who_update_dimension_tables_only)" + flash(message="Finished: task_who_update_dimension_tables_only [OK]", category="warning") return result @@ -406,6 +409,7 @@ def task_who_update_fact_table_incremental_only(self): who_service.run_update_fact_table_incremental_only() self.update_state(state=states.SUCCESS) result = "OK (task_who_update_dimension_tables_only)" + flash(message="Finished: task_who_update_fact_table_incremental_only [OK]", category="warning") return result @@ -419,6 +423,7 @@ def task_who_update_fact_table_initial_only(self): who_service.run_update_fact_table_initial_only() self.update_state(state=states.SUCCESS) result = "OK (task_who_update_fact_table_initial_only)" + flash(message="Finished: task_who_update_fact_table_initial_only [OK]", category="warning") return result @@ -432,6 +437,7 @@ def task_who_update_star_schema_incremental(self): who_service.run_update_star_schema_incremental() self.update_state(state=states.SUCCESS) result = "OK (task_who_update_star_schema_incremental)" + flash(message="Finished: task_who_update_star_schema_incremental [OK]", category="warning") return result @@ -445,6 +451,7 @@ def task_who_update_star_schema_initial(self): who_service.run_update_star_schema_initial() self.update_state(state=states.SUCCESS) result = "OK (task_who_update_star_schema_incremental)" + flash(message="Finished: task_who_update_star_schema_initial [OK]", category="warning") return result # ----------------------------------------------------------------------------------------------------------------