From 146cdec58549b7a8ae3ffc20fedce64c787ca498 Mon Sep 17 00:00:00 2001 From: Miklos Marton Date: Fri, 2 Aug 2024 13:35:41 +0200 Subject: [PATCH] Fix bug in test statistics generation --- src/backend/InvenTree/stock/api.py | 3 +-- src/backend/InvenTree/stock/serializers.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/stock/api.py b/src/backend/InvenTree/stock/api.py index 00119d1486..4e552ad445 100644 --- a/src/backend/InvenTree/stock/api.py +++ b/src/backend/InvenTree/stock/api.py @@ -1320,8 +1320,7 @@ class TestStatistics(GenericAPIView): ) def get(self, request, pk, *args, **kwargs): """Return test execution count matrix broken down by test result.""" - instance = self.get_object() - serializer = self.get_serializer(instance) + serializer = self.get_serializer(request.data) if request.resolver_match.url_name == 'api-test-statistics-by-part': serializer.context['type'] = 'by-part' elif request.resolver_match.url_name == 'api-test-statistics-by-build': diff --git a/src/backend/InvenTree/stock/serializers.py b/src/backend/InvenTree/stock/serializers.py index e92c133eb7..6f05d477c4 100644 --- a/src/backend/InvenTree/stock/serializers.py +++ b/src/backend/InvenTree/stock/serializers.py @@ -885,13 +885,15 @@ class TestStatisticsSerializer(serializers.Serializer): def to_representation(self, obj): """Just pass through the test statistics from the model.""" if self.context['type'] == 'by-part': - return obj.part_test_statistics( + return StockItemTestResult.part_test_statistics( + {}, self.context['pk'], self.context['finished_datetime_after'], self.context['finished_datetime_before'], ) elif self.context['type'] == 'by-build': - return obj.build_test_statistics( + return StockItemTestResult.build_test_statistics( + {}, self.context['pk'], self.context['finished_datetime_after'], self.context['finished_datetime_before'],