Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion conf/report/report-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/fixedheader/3.1.5/js/dataTables.fixedHeader.min.js"> </script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/fixedheader/3.1.5/css/fixedHeader.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="report.css">
<script type="text/javascript" charset="utf8" src="report.js"></script>
</head>
Expand All @@ -33,7 +35,50 @@
{% for tool in report %}
{ "orderDataType": "test-status" },
{% endfor %}
]
],
initComplete: function() {
this.api().columns([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]).every(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly does this do? do we have to have that list literal here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I listed them out to not have the dropdown for the tags (first 2 columns) but I'll see if this can be done in some other way

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will have to be changed whenever we add a new tool ? This sounds brittle. Can this be formulated as 'everything but the first two columns' instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is resolved in the latest commit. I'll also look into adding a separate JS file for the script. Thanks for the suggestions!

var column = this;
var select = $('<select><option value="Select"></option></select>')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question to consider: instead of having in-line implementation of functions, putting them in a separate JS file might be easier to maintain in the long term.
It is easy to accumulate important code that is hard to understand if buried in a large HTML template (not sure what are good practices are to break this up, as it seems that the closure takes a few values from the context (such as $(this).val()) - so possibly the function to be implemented externally needs explicit parameters; but that is good for documentation).

So while this looks not a large problem here at this point (and maybe the conclusion might be that this particular use might be benign), it might become some problem in the future. So worthwhile considering a general plan for code structuring.

.appendTo($(column.footer()).empty())
.on('change', function() {
var array = []
var val = $(this).val();
if(val.length > 1){
val = parseFloat(val.slice(0, -1));
} else {
val = parseFloat(val);
}
column.data().each(function(d, j) {
output = d.split('/');
tests_passed = output[0];
total_tests = output[1];
percentage = (tests_passed/total_tests)*100;

// 0 tests passed
if(tests_passed == val && tests_passed == 0 && tests_passed != ""){
array.push(d);
}
// At least 1 test passed
else if(tests_passed >= val && val == 1){
array.push(d);
}
// other cases
else if(percentage >= val && val > 1) {
array.push(d);
}
});
array = array.join('|');
column.search(array, true, false, true).draw();
} );
select.append('<option value="0">0</option>');
select.append('<option value="1">1</option>');
select.append('<option value="25%">25%</option>');
select.append('<option value="50%">50%</option>');
select.append('<option value="75%">75%</option>');
select.append('<option value="100%">All</option>');
} );
}
});
} );
</script>
Expand Down