2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-03 22:08:49 +00:00

Retrieve all stock item test results at once

This commit is contained in:
Oliver Walters 2022-04-29 01:27:58 +10:00
parent e0189be5a6
commit a0ca20ab04

View File

@ -1007,40 +1007,37 @@ function loadBuildOutputTable(build_info, options={}) {
return; return;
} }
rows.forEach(function(row) { // Retrieve stock results for the entire build
// Ignore if this row has already been updated (else, infinite loop!)
if (row.passed_tests) {
return;
}
// Request test result information for the particular build output
inventreeGet( inventreeGet(
'{% url "api-stock-test-result-list" %}', '{% url "api-stock-test-result-list" %}',
{ {
stock_item: row.pk, build: build_info.pk,
}, },
{ {
success: function(results) { success: function(results) {
// A list of tests that this stock item has passed // Iterate through each row and find matching test results
var passed_tests = {}; rows.forEach(function(row) {
var test_results = {};
// Keep a list of tests that this stock item has passed
results.forEach(function(result) { results.forEach(function(result) {
if (result.result) { if (result.stock_item == row.pk) {
passed_tests[result.key] = true; // This test result matches the particular stock item
if (!(result.key in test_results)) {
test_results[result.key] = result.result;
}
} }
}); });
row.passed_tests = passed_tests; row.passed_tests = test_results;
$(table).bootstrapTable('updateByUniqueId', row.pk, row, true); $(table).bootstrapTable('updateByUniqueId', row.pk, row, true);
}
}
)
}); });
} }
}
);
}
// Return the number of 'passed' tests in a given row // Return the number of 'passed' tests in a given row
function countPassedTests(row) { function countPassedTests(row) {