Fix bug in test statistics generation

This commit is contained in:
Miklos Marton 2024-08-02 13:35:41 +02:00
parent ad4a0e80db
commit 146cdec585
2 changed files with 5 additions and 4 deletions

View File

@ -1320,8 +1320,7 @@ class TestStatistics(GenericAPIView):
) )
def get(self, request, pk, *args, **kwargs): def get(self, request, pk, *args, **kwargs):
"""Return test execution count matrix broken down by test result.""" """Return test execution count matrix broken down by test result."""
instance = self.get_object() serializer = self.get_serializer(request.data)
serializer = self.get_serializer(instance)
if request.resolver_match.url_name == 'api-test-statistics-by-part': if request.resolver_match.url_name == 'api-test-statistics-by-part':
serializer.context['type'] = 'by-part' serializer.context['type'] = 'by-part'
elif request.resolver_match.url_name == 'api-test-statistics-by-build': elif request.resolver_match.url_name == 'api-test-statistics-by-build':

View File

@ -885,13 +885,15 @@ class TestStatisticsSerializer(serializers.Serializer):
def to_representation(self, obj): def to_representation(self, obj):
"""Just pass through the test statistics from the model.""" """Just pass through the test statistics from the model."""
if self.context['type'] == 'by-part': if self.context['type'] == 'by-part':
return obj.part_test_statistics( return StockItemTestResult.part_test_statistics(
{},
self.context['pk'], self.context['pk'],
self.context['finished_datetime_after'], self.context['finished_datetime_after'],
self.context['finished_datetime_before'], self.context['finished_datetime_before'],
) )
elif self.context['type'] == 'by-build': elif self.context['type'] == 'by-build':
return obj.build_test_statistics( return StockItemTestResult.build_test_statistics(
{},
self.context['pk'], self.context['pk'],
self.context['finished_datetime_after'], self.context['finished_datetime_after'],
self.context['finished_datetime_before'], self.context['finished_datetime_before'],