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