예제 #1
0
    def handle(self, *args, **options):
        super().handle(*args, **options)

        message = [
            f"Project: {self.project.name}",
            f"Create date: {self.project.created_date.strftime('%b %d %Y %H:%M')}",
            f"Work directory: {self.project.work_directory}",
            "\n",
            "Database:",
        ]

        for model_class in [CodebaseResource, DiscoveredPackage, ProjectError]:
            queryset = model_class.objects.project(self.project)
            message.append(f" - {model_class.__name__}: {queryset.count()}")

            if model_class == CodebaseResource:
                status_summary = count_group_by(queryset, "status")
                for status, count in status_summary.items():
                    status = status or "(no status)"
                    message.append(f"   - {status}: {count}")

        display_runs_log = options["verbosity"] > 0
        runs = self.project.runs.all()
        if runs:
            message.append("\nPipelines:")
            for run in runs:
                status_code = self.get_run_status_code(run)
                message.append(f" [{status_code}] {run.pipeline}")
                if display_runs_log and run.log:
                    for line in run.log.split("\n"):
                        message.append(3 * " " + line)

        for line in message:
            self.stdout.write(line)
예제 #2
0
def run_detail_view(request, uuid):
    template = "scanpipe/includes/run_modal_content.html"
    run = get_object_or_404(Run, uuid=uuid)
    status_summary = count_group_by(run.project.codebaseresources, "status")

    context = {
        "run": run,
        "status_summary": status_summary,
    }

    return render(request, template, context)
예제 #3
0
 def get_codebase_resources_summary(self, project):
     queryset = project.codebaseresources.all()
     return count_group_by(queryset, "status")