diff --git a/bublik/data/schemas/per_conf.json b/bublik/data/schemas/per_conf.json index a4a88e7c..296a7be9 100644 --- a/bublik/data/schemas/per_conf.json +++ b/bublik/data/schemas/per_conf.json @@ -156,6 +156,91 @@ "uniqueItems": true, "default": ["Configuration"] }, + "RUN_STATS_COLUMNS_DEFAULT": { + "description": "Column names to display by default in the run stats table, in display order", + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "const": "objective", + "title": "Objective", + "description": "Test objective" + }, + { + "const": "comments", + "title": "Notes", + "description": "User-provided comment for the test" + }, + { + "const": "total", + "title": "Total", + "description": "Total number of iterations" + }, + { + "const": "run", + "title": "Run", + "description": "Number of iterations actually run (all except skipped)" + }, + { + "const": "total_expected", + "title": "Expected Total", + "description": "Total number of expected iterations" + }, + { + "const": "passed", + "title": "Expected Passed", + "description": "Number of iterations that passed as expected" + }, + { + "const": "failed", + "title": "Expected Failed", + "description": "Number of iterations that failed as expected" + }, + { + "const": "total_unexpected", + "title": "Unexpected Total", + "description": "Total number of unexpected iterations" + }, + { + "const": "passed_unexpected", + "title": "Unexpected Passed", + "description": "Number of iterations that passed unexpectedly" + }, + { + "const": "failed_unexpected", + "title": "Unexpected Failed", + "description": "Number of iterations that failed unexpectedly" + }, + { + "const": "skipped", + "title": "Expected Skipped", + "description": "Number of iterations that were skipped as expected" + }, + { + "const": "skipped_unexpected", + "title": "Unexpected Skipped", + "description": "Number of iterations that were skipped unexpectedly" + }, + { + "const": "abnormal", + "title": "Abnormal", + "description": "Number of iterations that terminated abnormally" + } + ] + }, + "uniqueItems": true, + "default": [ + "run", + "passed", + "failed", + "passed_unexpected", + "failed_unexpected", + "skipped", + "skipped_unexpected", + "abnormal" + ] + }, "RUN_STATUS_META": { "description": "Represents meta name in meta_data.json that defines run status", "type": "string", diff --git a/bublik/interfaces/api_v2/results.py b/bublik/interfaces/api_v2/results.py index 95ede3d7..13fac3a3 100644 --- a/bublik/interfaces/api_v2/results.py +++ b/bublik/interfaces/api_v2/results.py @@ -10,6 +10,7 @@ from rest_framework.viewsets import ModelViewSet from bublik.core.cache import RunCache +from bublik.core.config.services import ConfigServices from bublik.core.result import ResultService from bublik.core.run.services import RunsChartGroupBy, RunService from bublik.core.run.stats import ( @@ -17,6 +18,7 @@ generate_runs_details, ) from bublik.core.utils import get_difference +from bublik.data.models import GlobalConfigs, TestIterationResult from bublik.data.serializers import ( RunCommentSerializer, TestIterationResultSerializer, @@ -98,7 +100,17 @@ def details(self, _request, pk=None): @action(detail=True, methods=['get']) def stats(self, _request, pk=None): requirements = self.request.query_params.get('requirements') - return Response({'results': RunService.get_run_stats(pk, requirements)}) + project_id = TestIterationResult.objects.get(id=pk).project.id + return Response( + { + 'results': RunService.get_run_stats(pk, requirements), + 'default_columns': ConfigServices.getattr_from_global( + GlobalConfigs.PER_CONF.name, + 'RUN_STATS_COLUMNS_DEFAULT', + project_id, + ), + }, + ) @action(detail=True, methods=['get']) def requirements(self, _request, pk=None):