|
34 | 34 | from vulnerabilities.forms import PackageSearchForm |
35 | 35 | from vulnerabilities.forms import PipelineSchedulePackageForm |
36 | 36 | from vulnerabilities.forms import VulnerabilitySearchForm |
| 37 | +from vulnerabilities.importers import LIVE_IMPORTERS_REGISTRY |
37 | 38 | from vulnerabilities.models import ImpactedPackage |
38 | 39 | from vulnerabilities.models import PipelineRun |
39 | 40 | from vulnerabilities.models import PipelineSchedule |
@@ -642,18 +643,59 @@ class PipelineScheduleListView(ListView, FormMixin): |
642 | 643 | form_class = PipelineSchedulePackageForm |
643 | 644 |
|
644 | 645 | def get_queryset(self): |
| 646 | + live_pipeline_ids = list(LIVE_IMPORTERS_REGISTRY.keys()) |
645 | 647 | form = self.form_class(self.request.GET) |
| 648 | + |
646 | 649 | if form.is_valid(): |
647 | | - return PipelineSchedule.objects.filter( |
| 650 | + return PipelineSchedule.objects.exclude(pipeline_id__in=live_pipeline_ids).filter( |
648 | 651 | pipeline_id__icontains=form.cleaned_data.get("search") |
649 | 652 | ) |
650 | | - return PipelineSchedule.objects.all() |
| 653 | + return PipelineSchedule.objects.exclude(pipeline_id__in=live_pipeline_ids) |
651 | 654 |
|
652 | 655 | def get_context_data(self, **kwargs): |
653 | 656 | context = super().get_context_data(**kwargs) |
654 | | - context["active_pipeline_count"] = PipelineSchedule.objects.filter(is_active=True).count() |
| 657 | + live_pipeline_ids = list(LIVE_IMPORTERS_REGISTRY.keys()) |
| 658 | + |
| 659 | + context["active_pipeline_count"] = ( |
| 660 | + PipelineSchedule.objects.exclude(pipeline_id__in=live_pipeline_ids) |
| 661 | + .filter(is_active=True) |
| 662 | + .count() |
| 663 | + ) |
| 664 | + context["disabled_pipeline_count"] = ( |
| 665 | + PipelineSchedule.objects.exclude(pipeline_id__in=live_pipeline_ids) |
| 666 | + .filter(is_active=False) |
| 667 | + .count() |
| 668 | + ) |
| 669 | + return context |
| 670 | + |
| 671 | + |
| 672 | +class LiveEvaluationPipelineScheduleListView(ListView, FormMixin): |
| 673 | + model = PipelineSchedule |
| 674 | + context_object_name = "schedule_list" |
| 675 | + template_name = "pipeline_dashboard.html" |
| 676 | + paginate_by = 20 |
| 677 | + form_class = PipelineSchedulePackageForm |
| 678 | + |
| 679 | + def get_queryset(self): |
| 680 | + live_pipeline_ids = list(LIVE_IMPORTERS_REGISTRY.keys()) |
| 681 | + form = self.form_class(self.request.GET) |
| 682 | + |
| 683 | + if form.is_valid(): |
| 684 | + return PipelineSchedule.objects.filter( |
| 685 | + pipeline_id__in=live_pipeline_ids, |
| 686 | + pipeline_id__icontains=form.cleaned_data.get("search"), |
| 687 | + ) |
| 688 | + return PipelineSchedule.objects.filter(pipeline_id__in=live_pipeline_ids) |
| 689 | + |
| 690 | + def get_context_data(self, **kwargs): |
| 691 | + context = super().get_context_data(**kwargs) |
| 692 | + live_pipeline_ids = list(LIVE_IMPORTERS_REGISTRY.keys()) |
| 693 | + |
| 694 | + context["active_pipeline_count"] = PipelineSchedule.objects.filter( |
| 695 | + pipeline_id__in=live_pipeline_ids, is_active=True |
| 696 | + ).count() |
655 | 697 | context["disabled_pipeline_count"] = PipelineSchedule.objects.filter( |
656 | | - is_active=False |
| 698 | + pipeline_id__in=live_pipeline_ids, is_active=False |
657 | 699 | ).count() |
658 | 700 | return context |
659 | 701 |
|
|
0 commit comments