Specific quality check for recorded entries
* adds a new command specifically for recorded entries
This commit is contained in:
		
							parent
							
								
									78868be772
								
							
						
					
					
						commit
						676b8e1e54
					
				@ -52,7 +52,6 @@ class Command(BaseKonovaCommand):
 | 
			
		||||
        self.__ema = Ema.objects.filter(**_filter)
 | 
			
		||||
 | 
			
		||||
    def perform_quality_check(self):
 | 
			
		||||
        # Interventions
 | 
			
		||||
        _runs = [
 | 
			
		||||
            (self.__interventions, InterventionQualityChecker),
 | 
			
		||||
            (self.__compensations, CompensationQualityChecker),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										58
									
								
								konova/management/commands/quality_check_recorded.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								konova/management/commands/quality_check_recorded.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,58 @@
 | 
			
		||||
"""
 | 
			
		||||
Author: Michel Peltriaux
 | 
			
		||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
 | 
			
		||||
Contact: ksp-servicestelle@sgdnord.rlp.de
 | 
			
		||||
Created on: 16.02.23
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
from compensation.models import Compensation, EcoAccount
 | 
			
		||||
from compensation.utils.quality import CompensationQualityChecker, EcoAccountQualityChecker
 | 
			
		||||
from ema.models import Ema
 | 
			
		||||
from ema.utils.quality import EmaQualityChecker
 | 
			
		||||
from intervention.models import Intervention
 | 
			
		||||
from intervention.utils.quality import InterventionQualityChecker
 | 
			
		||||
from konova.management.commands.setup import BaseKonovaCommand
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Command(BaseKonovaCommand):
 | 
			
		||||
    help = "Runs quality check on recorded entries"
 | 
			
		||||
 | 
			
		||||
    __interventions = []
 | 
			
		||||
    __compensations = []
 | 
			
		||||
    __ecoaccount = []
 | 
			
		||||
    __ema = []
 | 
			
		||||
 | 
			
		||||
    def handle(self, *args, **options):
 | 
			
		||||
        self.__get_objects()
 | 
			
		||||
        self.perform_quality_check()
 | 
			
		||||
 | 
			
		||||
    def __get_objects(self):
 | 
			
		||||
        _filter = {
 | 
			
		||||
            "recorded_id__isnull": False,
 | 
			
		||||
        }
 | 
			
		||||
        self.__interventions = Intervention.objects.filter(**_filter)
 | 
			
		||||
        self.__compensations = Compensation.objects.filter(
 | 
			
		||||
            intervention__recorded_id__isnull=False
 | 
			
		||||
        )
 | 
			
		||||
        self.__ecoaccount = EcoAccount.objects.filter(**_filter)
 | 
			
		||||
        self.__ema = Ema.objects.filter(**_filter)
 | 
			
		||||
 | 
			
		||||
    def perform_quality_check(self):
 | 
			
		||||
        _runs = [
 | 
			
		||||
            (self.__interventions, InterventionQualityChecker),
 | 
			
		||||
            (self.__compensations, CompensationQualityChecker),
 | 
			
		||||
            (self.__ecoaccount, EcoAccountQualityChecker),
 | 
			
		||||
            (self.__ema, EmaQualityChecker),
 | 
			
		||||
        ]
 | 
			
		||||
        eivs = set()
 | 
			
		||||
        for run in _runs:
 | 
			
		||||
            entries = run[0]
 | 
			
		||||
            CheckerClass = run[1]
 | 
			
		||||
            for entry in entries:
 | 
			
		||||
                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)
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user