diff --git a/src/covid19/blueprints/owid/owid_model.py b/src/covid19/blueprints/owid/owid_model.py index bdd53640915ab2771311da63d050c54084249439..e9b03ad3d34a2d67bd2563ce7d74ec765f6ef3dd 100644 --- a/src/covid19/blueprints/owid/owid_model.py +++ b/src/covid19/blueprints/owid/owid_model.py @@ -1,7 +1,9 @@ from sqlalchemy import and_, func from datetime import date +from sqlalchemy.orm import joinedload, load_only, defaultload, defer, undefer, query_expression, subqueryload +from sqlalchemy.sql import select + from database import db, ITEMS_PER_PAGE -from sqlalchemy.orm import joinedload from covid19.blueprints.application.application_model import ApplicationDateReported, ApplicationRegion @@ -279,6 +281,6 @@ class OwidData(db.Model): @classmethod def delete_data_for_one_day(cls, date_reported): - for data in cls.get_data_for_one_day(): - db.session.remove(data) - db.session.commit() + for data in cls.get_data_for_one_day(date_reported): + db.session.delete(data) + db.session.commit() diff --git a/src/covid19/blueprints/owid_test/owid_test_service.py b/src/covid19/blueprints/owid_test/owid_test_service.py index 4f9b847bb3f76be22c8574b4d7ca2f3ba7df5f48..7233e05dc4bf92d467ef53060afc0e2f61ebe156 100644 --- a/src/covid19/blueprints/owid_test/owid_test_service.py +++ b/src/covid19/blueprints/owid_test/owid_test_service.py @@ -31,7 +31,7 @@ class OwidTestService: i = 0 for data in OwidData.get_data_for_one_day(joungest_datum): i += 1 - line = " | " + str(i) + " | " + str(data.date_reported) + " | " + data.country.country + " | to be deleted" + line = " | " + str(i) + " | " + str(data.date_reported) + " | " + data.country.location + " | to be deleted" app.logger.info(line) app.logger.info("WhoData.delete_data_for_one_day(joungest_datum)") OwidData.delete_data_for_one_day(joungest_datum) diff --git a/src/covid19/blueprints/who/who_model.py b/src/covid19/blueprints/who/who_model.py index 12e0817b1408c488de0ea4153cfaaf9aa0384eed..dac88da082ee330e8415f148d23f978f46c36d29 100644 --- a/src/covid19/blueprints/who/who_model.py +++ b/src/covid19/blueprints/who/who_model.py @@ -1,8 +1,8 @@ from sqlalchemy import and_, func from datetime import date -from database import db, ITEMS_PER_PAGE from sqlalchemy.orm import joinedload, load_only, defaultload, defer, undefer, query_expression, subqueryload from sqlalchemy.sql import select +from database import db, ITEMS_PER_PAGE from covid19.blueprints.application.application_model import ApplicationDateReported, ApplicationRegion diff --git a/src/covid19/blueprints/who_test/who_test_service.py b/src/covid19/blueprints/who_test/who_test_service.py index d976957d184b68b5735165305b811527f4161f29..ac7b0e72c71c9c01345dfbe6bfd3558753d34b3d 100644 --- a/src/covid19/blueprints/who_test/who_test_service.py +++ b/src/covid19/blueprints/who_test/who_test_service.py @@ -24,9 +24,9 @@ class WhoTestService: app.logger.info(joungest_datum) app.logger.info("WhoData.get_data_for_one_day(joungest_datum):") i = 0 - for who_data in WhoData.get_data_for_one_day(joungest_datum): + for data in WhoData.get_data_for_one_day(joungest_datum): i += 1 - line = " | " + str(i) + " | " + str(who_data.date_reported) + " | " + who_data.country.country + " | to be deleted" + line = " | " + str(i) + " | " + str(data.date_reported) + " | " + data.country.country + " | to be deleted" app.logger.info(line) app.logger.info("WhoData.delete_data_for_one_day(joungest_datum)") WhoData.delete_data_for_one_day(joungest_datum)