From 5a028e01517505c8f4530317b1151d208c27e193 Mon Sep 17 00:00:00 2001
From: thomaswoehlke <thomas.woehlke@gmail.com>
Date: Tue, 19 Jan 2021 14:40:28 +0100
Subject: [PATCH] ### 0.0.9 Release * Fixed #18 /europe/update: Download *
 Fixed #19 /europe/update: Import File to DB * Issue #20 /europe/update:
 Update DB * Issue #21 update_date_reported * Issue #22 update_continent *
 Issue #23 update_country * Issue #24 update_data * Issue #3 ORM: 3NF for
 ecdc_europa_data_import * Issue #4 data update for 3NF
 ecdc_europa_data_import

---
 org/woehlke/covid19/europe/europe_model.py        |  5 +++++
 .../covid19/europe/europe_service_update.py       | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/org/woehlke/covid19/europe/europe_model.py b/org/woehlke/covid19/europe/europe_model.py
index 35e80f76..858f5ba6 100644
--- a/org/woehlke/covid19/europe/europe_model.py
+++ b/org/woehlke/covid19/europe/europe_model.py
@@ -39,6 +39,11 @@ class EuropeDataImportTable(db.Model):
         sql = "select distinct date_rep, year_week from europe_data_import order by year_week desc"
         return db.session.execute(sql)
 
+    @classmethod
+    def get_continent(cls):
+        sql = "select distinct continent_exp from europe_data_import order by continent_exp asc"
+        return db.session.execute(sql)
+
 
 class EuropeDateReported(db.Model):
     __tablename__ = 'europe_date_reported'
diff --git a/org/woehlke/covid19/europe/europe_service_update.py b/org/woehlke/covid19/europe/europe_service_update.py
index 7e821810..7fec89cd 100644
--- a/org/woehlke/covid19/europe/europe_service_update.py
+++ b/org/woehlke/covid19/europe/europe_service_update.py
@@ -1,7 +1,7 @@
 import os
 import psycopg2
 from database import db, app
-from org.woehlke.covid19.europe.europe_model import EuropeDataImportTable, EuropeDateReported
+from org.woehlke.covid19.europe.europe_model import EuropeDataImportTable, EuropeDateReported, EuropeContinent
 
 
 class EuropeServiceUpdate:
@@ -26,7 +26,7 @@ class EuropeServiceUpdate:
         for result_item in result_date_rep:
             my_date_rep = result_item['date_rep']
             my_year_week = result_item['year_week']
-            app.logger.info("| "+my_date_rep+" | "+my_year_week+" |")
+            app.logger.info("| " + my_date_rep + " | " + my_year_week + " |")
             o = EuropeDateReported(
                 date_rep=my_date_rep,
                 year_week=my_year_week
@@ -40,7 +40,16 @@ class EuropeServiceUpdate:
     def __update_continent(self):
         app.logger.info(" __update_continent [begin]")
         app.logger.info("------------------------------------------------------------")
-        app.logger.info(" ... ")
+        EuropeContinent.remove_all()
+        result_continent = EuropeDataImportTable.get_continent()
+        for result_item in result_continent:
+            my_continent_exp = result_item['continent_exp']
+            app.logger.info("| " + my_continent_exp + " |")
+            o = EuropeContinent(
+                continent_exp=my_continent_exp
+            )
+            db.session.add(o)
+        db.session.commit()
         app.logger.info(" __update_continent [done]")
         app.logger.info("------------------------------------------------------------")
         return self
-- 
GitLab