recorded_quality_check #297

Merged
mpeltriaux merged 2 commits from recorded_quality_check into master 2023-02-21 08:06:36 +01:00
Showing only changes of commit 1438cf4e89 - Show all commits

View File

@ -12,6 +12,7 @@ from ema.utils.quality import EmaQualityChecker
from intervention.models import Intervention
from intervention.utils.quality import InterventionQualityChecker
from konova.management.commands.setup import BaseKonovaCommand
from user.models import User
class Command(BaseKonovaCommand):
@ -38,13 +39,20 @@ class Command(BaseKonovaCommand):
self.__ema = Ema.objects.filter(**_filter)
def perform_quality_check(self):
""" Performs quality check and unrecords failing entries
"""
_runs = [
(self.__interventions, InterventionQualityChecker),
#(self.__interventions, InterventionQualityChecker),
(self.__compensations, CompensationQualityChecker),
(self.__ecoaccount, EcoAccountQualityChecker),
(self.__ema, EmaQualityChecker),
#(self.__ecoaccount, EcoAccountQualityChecker),
#(self.__ema, EmaQualityChecker),
]
eivs = set()
invalid_entries = set()
admin_user = User.objects.get(
username="kspRoot"
)
for run in _runs:
entries = run[0]
CheckerClass = run[1]
@ -52,7 +60,7 @@ class Command(BaseKonovaCommand):
checker = CheckerClass(entry)
checker.run_check()
if not checker.valid and CheckerClass is CompensationQualityChecker:
eivs.add(entry.intervention.identifier)
#self._write_error(f"{entry.identifier};{';'.join(str(msg) for msg in checker.messages)}")
for eiv in eivs:
self._write_warning(eiv)
invalid_entries.add(entry.intervention)
for e in invalid_entries:
e.set_unrecorded(user=admin_user)
self._write_warning(e.identifier)