Ejemplo n.º 1
0
    def run(self, manual=False):
        hardcoded_reports = HardcodedReport.objects.filter(report=self)
        queries = Query.objects.filter(report=self)

        runs = []
        for report in hardcoded_reports:
            runs.append(report.run(manual=manual))
        for query in queries:
            runs.append(query.run(manual=manual))
        
        if self.alert:
            for run in runs: 
                for result in run.result_set.all():
                    for row_map in result.table_rendered().row_maps():
                        if 'EMPLID' in row_map:
                            # for more complicated Alert handling, we need
                            # to pass in actual unique_fields
                            unique_fields = ["EMPLID"]
                            Alert.create(row_map, self.alert, unique_fields)

        for rule in self.expired_schedule_rules():
            rule.set_next_run()
            rule.save()

        failed_runs = [run for run in runs if run.success == False]
        if len(failed_runs) > 0:
            self.failure_notification(failed_runs[0])

        return runs
Ejemplo n.º 2
0
    def run(self, manual=False):
        hardcoded_reports = HardcodedReport.objects.filter(report=self)
        queries = Query.objects.filter(report=self)

        runs = []
        for report in hardcoded_reports:
            runs.append(report.run(manual=manual))
        for query in queries:
            runs.append(query.run(manual=manual))

        if self.alert:
            for run in runs:
                for result in run.result_set.all():
                    for row_map in result.table_rendered().row_maps():
                        if 'EMPLID' in row_map:
                            # for more complicated Alert handling, we need
                            # to pass in actual unique_fields
                            unique_fields = ["EMPLID"]
                            Alert.create(row_map, self.alert, unique_fields)

        for rule in self.expired_schedule_rules():
            rule.set_next_run()
            rule.save()

        failed_runs = [run for run in runs if run.success == False]
        if len(failed_runs) > 0:
            self.failure_notification(failed_runs[0])

        return runs