diff --git a/README.md b/README.md index a90bb5c71842dc92afff8bfa8318e70055e77ce3..ec518e2f4b1d3c3d08d7749715809b06b5354b00 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,10 @@ class WhoGlobalDataImportTable(db.Model): * Issue #22 update_continent * Issue #23 update_country * Issue #24 update_data +* Issue #25 /who/update/initial update_data_initial +* Issue #26 /admin/database/dump +* Issue #27 /admin/database/drop +* Issue #28 /admin/database/import * Issue #3 ORM: 3NF for ecdc_europa_data_import * Issue #4 data update for 3NF ecdc_europa_data_import diff --git a/app.py b/app.py index 54193018ee74ed41412b8c0c20b81bd43c340947..79d87f02f5117c9bbbb741430d6f6a89f2bfd3dd 100644 --- a/app.py +++ b/app.py @@ -309,6 +309,33 @@ def url_alive_message_start(): return redirect(url_for('home')) +@app.route('/admin/database/dump') +def url_admin_database_dump(): + app.logger.info("url_admin_database_dump [start]") + alive_message_task.apply_async() + flash("alive_message_task started") + app.logger.info("url_admin_database_dump [done]") + return redirect(url_for('home')) + + +@app.route('/admin/database/import') +def url_admin_database_import(): + app.logger.info("url_admin_database_import [start]") + alive_message_task.apply_async() + flash("alive_message_task started") + app.logger.info("url_admin_database_import [done]") + return redirect(url_for('home')) + + +@app.route('/admin/database/drop') +def url_admin_database_drop(): + app.logger.info("url_admin_database_drop [start]") + alive_message_task.apply_async() + flash("alive_message_task started") + app.logger.info("url_admin_database_drop [done]") + return redirect(url_for('home')) + + if __name__ == '__main__': dictConfig(my_logging_comfig) db.create_all() diff --git a/org/woehlke/covid19/admin/__init__.py b/org/woehlke/covid19/admin/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/org/woehlke/covid19/admin/admin_service.py b/org/woehlke/covid19/admin/admin_service.py new file mode 100644 index 0000000000000000000000000000000000000000..969bd8f8e699e49833ed0829c3d46fd82a68c045 --- /dev/null +++ b/org/woehlke/covid19/admin/admin_service.py @@ -0,0 +1,41 @@ +import os +from database import app + +admin_service = None + + +class AdminService: + def __init__(self, database): + app.logger.info("------------------------------------------------------------") + app.logger.info(" Admin Service [init]") + app.logger.info("------------------------------------------------------------") + self.__database = database + self.limit_nr = 20 + app.logger.info("------------------------------------------------------------") + app.logger.info(" Admin Service [ready]") + + def run_admin_database_dump(self): + app.logger.info(" run update countries [begin]") + app.logger.info("------------------------------------------------------------") + app.logger.info("... TBD") + app.logger.info(" run update countries [done]") + app.logger.info("------------------------------------------------------------") + return self + + def run_admin_database_import(self): + app.logger.info(" run update countries [begin]") + app.logger.info("------------------------------------------------------------") + app.logger.info("... TBD") + app.logger.info(" run update countries [done]") + app.logger.info("------------------------------------------------------------") + return self + + def run_admin_database_drop(self): + app.logger.info(" run update countries [begin]") + app.logger.info("------------------------------------------------------------") + self.__database.drop_all() + self.__database.create_all() + app.logger.info("") + app.logger.info(" run update countries [done]") + app.logger.info("------------------------------------------------------------") + return self