From 7f6c5787ca58280e14245d03b411feb592b55087 Mon Sep 17 00:00:00 2001
From: thomaswoehlke <thomas.woehlke@gmail.com>
Date: Wed, 26 May 2021 17:12:45 +0200
Subject: [PATCH] Refactoring: vaccination

---
 .../blueprints/app_all/all_model.py           |  7 ++++
 .../blueprints/data_rki/rki_service_update.py | 34 +++++++++----------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/flask_covid19/blueprints/app_all/all_model.py b/src/flask_covid19/blueprints/app_all/all_model.py
index 15f9b5da..3f8c6e83 100644
--- a/src/flask_covid19/blueprints/app_all/all_model.py
+++ b/src/flask_covid19/blueprints/app_all/all_model.py
@@ -21,6 +21,13 @@ class BlueprintEntity(db.Model):
             db.session.rollback()
         return num_rows_deleted
 
+    @classmethod
+    def delete_all(cls):
+        for o in cls.find_all():
+            o.remove()
+        db.session.commit()
+        return None
+
     @classmethod
     def get_all_as_page(cls, page: int):
         return db.session.query(cls)\
diff --git a/src/flask_covid19/blueprints/data_rki/rki_service_update.py b/src/flask_covid19/blueprints/data_rki/rki_service_update.py
index db7df076..00e6045b 100644
--- a/src/flask_covid19/blueprints/data_rki/rki_service_update.py
+++ b/src/flask_covid19/blueprints/data_rki/rki_service_update.py
@@ -22,7 +22,7 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
     def __full_update_date_datenstand(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_date_datenstand [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiDatenstand.remove_all()
+        RkiDatenstand.delete_all()
         i = 0
         output_lines = []
         for datum_of_import in RkiImport.get_date_datenstand_of_all_import():
@@ -42,7 +42,7 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
     def __full_update_date_ref_datum(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_date_ref_datum [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiRefDatum.remove_all()
+        RkiRefDatum.delete_all()
         i = 0
         output_lines = []
         for datum_of_import in RkiImport.get_date_ref_datum_of_all_import():
@@ -62,7 +62,7 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
     def __full_update_date_reported(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_date_reported [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiMeldedatum.remove_all()
+        RkiMeldedatum.delete_all()
         i = 0
         output_lines = []
         for datum_of_import in RkiImport.get_meldedatum_list():
@@ -85,7 +85,7 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
     def __full_update_altersgruppe(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_altersgruppe [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiAltersgruppe.remove_all()
+        RkiAltersgruppe.delete_all()
         app.logger.info("")
         i = 0
         output_lines = []
@@ -108,13 +108,13 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
         return self
 
     def __clean_bundesland(self):
-        RkiBundesland.remove_all()
+        RkiBundesland.delete_all()
         return self
 
     def __full_update_bundesland(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_bundesland [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiBundesland.remove_all()
+        RkiBundesland.delete_all()
         app.logger.info("")
         i = 0
         output_lines = []
@@ -139,12 +139,12 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
         return self
 
     def __clean_landkreis(self):
-        RkiLandkreis.remove_all()
+        RkiLandkreis.delete_all()
         self.__clean_bundesland()
         return self
 
     def __full_update_landkreis(self):
-        RkiLandkreis.remove_all()
+        RkiLandkreis.delete_all()
         self.__full_update_bundesland()
         app.logger.info(" RkiServiceUpdateFull.__full_update_landkreis [begin]")
         app.logger.info("------------------------------------------------------------")
@@ -179,13 +179,13 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
         return self
 
     def __clean_data(self):
-        RkiData.remove_all()
+        RkiData.delete_all()
         return self
 
     def __full_update_data(self):
         app.logger.info(" RkiServiceUpdateFull.__full_update_data [begin]")
         app.logger.info("------------------------------------------------------------")
-        RkiData.remove_all()
+        RkiData.delete_all()
         i = 0
         d = 0
         k = 0
@@ -267,12 +267,12 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
         return self
 
     def __clean_dimension_tables(self):
-        RkiMeldedatum.remove_all()
-        RkiDatenstand.remove_all()
-        RkiRefDatum.remove_all()
-        RkiAltersgruppe.remove_all()
-        RkiLandkreis.remove_all()
-        RkiBundesland.remove_all()
+        RkiMeldedatum.delete_all()
+        RkiDatenstand.delete_all()
+        RkiRefDatum.delete_all()
+        RkiAltersgruppe.delete_all()
+        RkiLandkreis.delete_all()
+        RkiBundesland.delete_all()
         return self
 
     def full_update_dimension_tables(self):
@@ -286,7 +286,7 @@ class RkiServiceUpdateFull(RkiServiceUpdateBase):
         return self
 
     def __clean_fact_table(self):
-        RkiData.remove_all()
+        RkiData.delete_all()
         return self
 
     def full_update_fact_table(self):
-- 
GitLab