diff --git a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service.py b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service.py index 8da5047a89cee5b3b45ff2b7a179b0b102bf55c3..36b21f12c230544993c8561d21aca8ed6bf1a7e4 100644 --- a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service.py +++ b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service.py @@ -52,13 +52,11 @@ class RkiBundeslaenderService: return self def run_update_star_schema_incremental(self): - self.service_download.download_file() self.service_import.import_file() self.service_update.update_star_schema_incremental() return self def run_update_star_schema_initial(self): - self.service_download.download_file() self.service_import.import_file() self.service_update.update_star_schema_initial() return self diff --git a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py index 424203080f9c63b7ed8012097d2fa818a117ee1f..db8e6ef35f49a11d186e5bd042f3947004c457ab 100644 --- a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py +++ b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py @@ -1,9 +1,11 @@ from flask import render_template, redirect, url_for, flash, Blueprint from sqlalchemy.exc import OperationalError from flask_admin.contrib.sqla import ModelView +from celery import states from database import app, admin, db from covid19.blueprints.application.application_workers import celery +from covid19.blueprints.application.application_services import rki_service_bundeslaender from covid19.blueprints.rki_bundeslaender.rki_bundeslaender_model import RkiBundeslaender from covid19.blueprints.rki_bundeslaender.rki_bundeslaender_model_import import RkiBundeslaenderImport from covid19.blueprints.application.application_model_transient import ApplicationPage @@ -58,38 +60,54 @@ def url_rki_bundeslaender_imported(page=1): @celery.task(bind=True) -def task_rki_bundeslaender_task_update_starschema_initial(): - pass +def task_rki_bundeslaender_task_update_starschema_initial(self): + self.update_state(state=states.STARTED) + rki_service_bundeslaender.run_update_star_schema_incremental() + self.update_state(state=states.SUCCESS) + result = "OK (task_rki_bundeslaender_task_update_starschema_initial)" + return result @celery.task(bind=True) -def task_rki_bundeslaender_task_update_starschema_incremental(): - pass +def task_rki_bundeslaender_task_update_starschema_incremental(self): + self.update_state(state=states.STARTED) + rki_service_bundeslaender.run_update_star_schema_incremental() + self.update_state(state=states.SUCCESS) + result = "OK (task_rki_bundeslaender_task_update_starschema_incremental)" + return result @celery.task(bind=True) -def task_rki_bundeslaender_task_download_only(): - pass +def task_rki_bundeslaender_task_import_only(self): + self.update_state(state=states.STARTED) + rki_service_bundeslaender.run_import_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_rki_bundeslaender_task_import_only)" + return result @celery.task(bind=True) -def task_rki_bundeslaender_task_import_only(): - pass +def task_rki_bundeslaender_task_update_facttable_incremental_only(self): + self.update_state(state=states.STARTED) + rki_service_bundeslaender.run_update_fact_table_incremental_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_rki_bundeslaender_task_update_facttable_incremental_only)" + return result @celery.task(bind=True) -def task_rki_bundeslaender_task_update_facttable_incremental_only(): - pass - - -@celery.task(bind=True) -def task_rki_bundeslaender_task_update_facttable_initial_only(): - pass +def task_rki_bundeslaender_task_update_facttable_initial_only(self): + self.update_state(state=states.STARTED) + rki_service_bundeslaender.update_fact_table_initial_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_rki_bundeslaender_task_update_facttable_initial_only)" + return result @app_rki_bundeslaender.route('/task/update/star_schema/initial') def url_rki_bundeslaender_task_update_starschema_initial(): app.logger.info("url_rki_bundeslaender_task_update_starschema_initial [start]") + rki_service_bundeslaender.run_download_only() task_rki_bundeslaender_task_update_starschema_initial.apply_async() return redirect(url_for('rki_bundeslaender.url_rki_tasks')) @@ -97,6 +115,7 @@ def url_rki_bundeslaender_task_update_starschema_initial(): @app_rki_bundeslaender.route('/task/update/star_schema/incremental') def url_rki_bundeslaender_task_update_starschema_incremental(): app.logger.info("url_rki_bundeslaender_task_update_starschema_incremental [start]") + rki_service_bundeslaender.run_download_only() task_rki_bundeslaender_task_update_starschema_incremental.apply_async() return redirect(url_for('rki_bundeslaender.url_rki_tasks')) @@ -104,7 +123,7 @@ def url_rki_bundeslaender_task_update_starschema_incremental(): @app_rki_bundeslaender.route('/task/download/only') def url_rki_bundeslaender_task_download_only(): app.logger.info("url_rki_bundeslaender_task_download_only [start]") - task_rki_bundeslaender_task_download_only.apply_async() + rki_service_bundeslaender.run_download_only() return redirect(url_for('rki_bundeslaender.url_rki_tasks'))