Skip to content

Commit

Permalink
Merge test-statistics urls
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Jun 24, 2024
1 parent e21fd4a commit 4267b83
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ <h3>

{% if build.part.trackable > 0 %}
onPanelLoad("test-statistics", function() {
prepareTestStatisticsTable('build', '{% url "api-test-statistics/by-build" build.pk %}')
prepareTestStatisticsTable('build', '{% url "api-test-statistics-by-build" build.pk %}')
});
{% endif %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/part/templates/part/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ <h4>{% trans "Part Manufacturers" %}</h4>
});
});
onPanelLoad("test-statistics", function() {
prepareTestStatisticsTable('part', '{% url "api-test-statistics" "by-part" part.pk %}')
prepareTestStatisticsTable('part', '{% url "api-test-statistics-by-part" part.pk %}')
});

onPanelLoad("part-stock", function() {
Expand Down
27 changes: 22 additions & 5 deletions src/backend/InvenTree/stock/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,13 @@ class TestStatistics(GenericAPIView):
responses={200: StockSerializers.TestStatisticsSerializer(many=False)}
)
def get(self, request, pk, *args, **kwargs):
"""Return test execution count matrix broken downs by test result."""
"""Return test execution count matrix broken down by test result."""
instance = self.get_object()
serializer = self.get_serializer(instance)
serializer.context['type'] = kwargs['type']
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':
serializer.context['type'] = 'by-build'
serializer.context['finished_datetime_after'] = self.request.query_params.get(
'finished_datetime_after'
)
Expand Down Expand Up @@ -1716,9 +1719,23 @@ def destroy(self, request, *args, **kwargs):
test_statistics_api_urls = [
# Test statistics endpoints
path(
'<str:type>/',
'by-part/',
include([
path('<int:pk>/', TestStatistics.as_view(), name='api-test-statistics')
path(
'<int:pk>/',
TestStatistics.as_view(),
name='api-test-statistics-by-part',
)
]),
)
),
path(
'by-build/',
include([
path(
'<int:pk>/',
TestStatistics.as_view(),
name='api-test-statistics-by-build',
)
]),
),
]
4 changes: 2 additions & 2 deletions src/frontend/src/enums/ApiEndpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export enum ApiEndpoints {
stock_assign = 'stock/assign/',
stock_status = 'stock/status/',
stock_install = 'stock/:id/install',
build_test_statistics = 'stock/test-statistics/by-build/:id',
part_test_statistics = 'stock/test-statistics/by-part/:id',
build_test_statistics = 'stock/test-statistics-by-build/:id',
part_test_statistics = 'stock/test-statistics-by-part/:id',

// Generator API endpoints
generate_batch_code = 'generate/batch-code/',
Expand Down

0 comments on commit 4267b83

Please sign in to comment.