Deployment preparation
* adds unrecording to invalid entries * reduces quality check runs on entries of interest (compensations)
This commit is contained in:
parent
676b8e1e54
commit
1438cf4e89
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user