From 6661ecf33e5b61610beca2cb70c066dabdf025cc Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Sat, 6 Feb 2021 23:58:56 +0100 Subject: [PATCH] dev for Milestone 0.0.14 --- src/covid19/blueprints/who/who_views.py | 206 ++++++++++++++---------- 1 file changed, 123 insertions(+), 83 deletions(-) diff --git a/src/covid19/blueprints/who/who_views.py b/src/covid19/blueprints/who/who_views.py index c0a0b7cd..bb4d7f5d 100644 --- a/src/covid19/blueprints/who/who_views.py +++ b/src/covid19/blueprints/who/who_views.py @@ -23,70 +23,173 @@ app_who = Blueprint('who', __name__, template_folder='templates') @celery.task(bind=True) -def task_who_run_update_full(self, import_file=True): +def task_who_download_only(self): + logger = get_task_logger(__name__) self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_who_download_only [OK] ") + logger.info("------------------------------------------------------------") + who_service.run_download_only() + self.update_state(state=states.SUCCESS) + result = "OK (task_who_download_only)" + return result + + +@celery.task(bind=True) +def task_who_import_only(self): logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) logger.info("------------------------------------------------------------") - logger.info(" Received: task_who_run_update_full [OK] ") + logger.info(" Received: task_who_import_only [OK] ") logger.info("------------------------------------------------------------") - who_service.run_update(import_file) + who_service.run_import_only() self.update_state(state=states.SUCCESS) - result = "OK (task_who_run_update)" + result = "OK (task_who_import_only)" return result @celery.task(bind=True) -def task_who_update_short(self): +def task_who_update_dimension_tables_only(self): logger = get_task_logger(__name__) self.update_state(state=states.STARTED) logger.info("------------------------------------------------------------") - logger.info(" Received: task_who_update_short [OK] ") + logger.info(" Received: task_who_update_dimension_tables_only [OK] ") logger.info("------------------------------------------------------------") - who_service.run_update_short() + who_service.run_update_dimension_tables_only() self.update_state(state=states.SUCCESS) - result = "OK (task_who_update_short)" + result = "OK (task_who_update_dimension_tables_only)" return result @celery.task(bind=True) -def task_who_update_initial(self): +def task_who_update_fact_table_incremental_only(self): logger = get_task_logger(__name__) self.update_state(state=states.STARTED) logger.info("------------------------------------------------------------") - logger.info(" Received: task_who_update_initial [OK] ") + logger.info(" Received: task_who_update_fact_table_incremental_only [OK] ") logger.info("------------------------------------------------------------") - who_service.run_update_initial() + who_service.run_update_fact_table_incremental_only() self.update_state(state=states.SUCCESS) - result = "OK (task_who_update_initial)" + result = "OK (task_who_update_dimension_tables_only)" return result @celery.task(bind=True) -def task_who_import_only(self): +def task_who_update_fact_table_initial_only(self): logger = get_task_logger(__name__) self.update_state(state=states.STARTED) logger.info("------------------------------------------------------------") - logger.info(" Received: task_who_import_only [OK] ") + logger.info(" Received: task_who_update_fact_table_initial_only [OK] ") logger.info("------------------------------------------------------------") - who_service.who_service_import.import_file() + who_service.run_update_fact_table_initial_only() self.update_state(state=states.SUCCESS) - result = "OK (task_who_import_only)" + result = "OK (task_who_update_fact_table_initial_only)" return result @celery.task(bind=True) -def task_who_update_only(self): +def task_who_update_star_schema_incremental(self): logger = get_task_logger(__name__) self.update_state(state=states.STARTED) logger.info("------------------------------------------------------------") - logger.info(" Received: task_who_update_only [OK] ") + logger.info(" Received: task_who_update_star_schema_incremental [OK] ") logger.info("------------------------------------------------------------") - who_service.who_service_update.update_only_db() + who_service.run_update_star_schema_incremental() self.update_state(state=states.SUCCESS) - result = "OK (task_who_update_only)" + result = "OK (task_who_update_star_schema_incremental)" return result +@celery.task(bind=True) +def task_who_update_star_schema_initial(self): + logger = get_task_logger(__name__) + self.update_state(state=states.STARTED) + logger.info("------------------------------------------------------------") + logger.info(" Received: task_who_update_star_schema_initial [OK] ") + logger.info("------------------------------------------------------------") + who_service.run_update_star_schema_initial() + self.update_state(state=states.SUCCESS) + result = "OK (task_who_update_star_schema_incremental)" + return result + + +@app_who.route('/task/download/only') +def url_task_who_download_only(): + app.logger.info("url_who_task_download_only [start]") + who_service.run_download_only() + flash("who_service.run_download_only ok") + app.logger.info("url_who_task_download_only [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/import/only') +def url_task_who_import_only(): + app.logger.info("url_who_update_run [start]") + task_who_import_only.apply_async() + flash("who_service.run_update started") + flash(message="long running background task started", category="warning") + app.logger.info("url_who_update_run [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/update/dimension-tables/only') +def url_task_who_update_dimension_tables_only(): + app.logger.info("url_task_who_update_dimension_tables_only [start]") + task_who_update_dimension_tables_only.apply_async() + flash("task_who_update_dimension_tables_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_who_update_dimension_tables_only [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/update/fact-table/incremental/only') +def url_task_who_update_fact_table_incremental_only(): + app.logger.info("url_task_who_update_fact_table_incremental_only [start]") + who_service.run_download_only() + flash("who_service.run_download_only ok") + task_who_update_fact_table_incremental_only.apply_async() + flash("task_who_update_fact_table_incremental_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_who_update_fact_table_incremental_only [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/update/fact-table/initial/only') +def url_task_who_update_fact_table_initial_only(): + app.logger.info("url_task_who_update_fact_table_initial_only [start]") + who_service.run_download_only() + flash("who_service.who_service_download.download_file ok") + task_who_update_fact_table_initial_only.apply_async() + flash("task_who_update_fact_table_initial_only started") + flash(message="long running background task started", category="warning") + app.logger.info("url_who_task_update_full [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/update/star_schema/initial') +def url_task_who_update_star_schema_initial(): + app.logger.info("url_who_task_update_full [start]") + who_service.run_download_only() + flash("who_service.who_service_download.download_file ok") + task_who_update_star_schema_initial.apply_async() + flash("task_who_update_star_schema_initial started") + flash(message="long running background task started", category="warning") + app.logger.info("url_who_task_update_full [done]") + return redirect(url_for('url_who_tasks')) + + +@app_who.route('/task/update/star_schema/incremental') +def url_task_who_update_star_schema_incremental(): + app.logger.info("url_task_who_update_star_schema_incremental [start]") + who_service.run_download_only() + flash("who_service.who_service_download.download_file ok") + task_who_update_star_schema_incremental.apply_async() + flash("task_who_run_update_full started") + flash(message="long running background task started", category="warning") + app.logger.info("url_task_who_update_star_schema_incremental [done]") + return redirect(url_for('url_who_tasks')) + + @app_who.route('/info') def url_who_info(): page_info = ApplicationPage('WHO', "Info") @@ -378,66 +481,3 @@ def url_who_germany(page=1): who_country=who_country_germany, page_data=page_data, page_info=page_info) - - -@app_who.route('/task/download/only') -def url_who_task_download_only(): - app.logger.info("url_who_task_download_only [start]") - who_service.who_service_download.download_file() - flash("who_service.who_service_download.download_file ok") - flash(message="long running background task started", category="warning") - app.logger.info("url_who_task_download_only [done]") - return redirect(url_for('url_who_tasks')) - - -@app_who.route('/task/import/only') -def url_who_task_import_only(): - app.logger.info("url_who_update_run [start]") - task_who_import_only.apply_async() - flash("who_service.run_update started") - flash(message="long running background task started", category="warning") - app.logger.info("url_who_update_run [done]") - return redirect(url_for('url_who_tasks')) - - -@app_who.route('/task/update/only') -def url_who_task_update_only(): - app.logger.info("url_who_update_run [start]") - task_who_update_only.apply_async() - flash("task_who_update_only started") - flash(message="long running background task started", category="warning") - app.logger.info("url_who_update_run [done]") - return redirect(url_for('url_who_tasks')) - - -@app_who.route('/task/update/initial') -def url_who_task_update_initial(): - who_service.who_service_download.download_file() - flash("who_service.who_service_download.download_file ok") - task_who_update_initial.apply_async() - flash("task_who_update_initial started") - flash(message="long running background task started", category="warning") - return redirect(url_for('url_who_tasks')) - - -@app_who.route('/task/update/short') -def url_who_task_update_short(): - who_service.who_service_download.download_file() - flash("who_service.who_service_download.download_file ok") - task_who_update_short.apply_async() - flash("task_who_update_short started") - flash(message="long running background task started", category="warning") - return redirect(url_for('url_who_tasks')) - - -@app_who.route('/task/update/full') -def url_who_task_update_full(): - app.logger.info("url_who_task_update_full [start]") - who_service.who_service_download.download_file() - flash("who_service.who_service_download.download_file ok") - task_who_run_update_full.apply_async() - flash("task_who_run_update_full started") - flash(message="long running background task started", category="warning") - app.logger.info("url_who_task_update_full [done]") - return redirect(url_for('url_who_tasks')) - -- GitLab