Fix datasource availability sorting (#7451)

* Fix availability sorting

* Style change
This commit is contained in:
Qi Shu 2019-04-14 10:09:57 -07:00 committed by Gian Merlino
parent 7a38d28cf3
commit 9b5c216684
1 changed files with 11 additions and 1 deletions

View File

@ -386,7 +386,12 @@ GROUP BY 1`);
Header: 'Availability', Header: 'Availability',
id: 'availability', id: 'availability',
filterable: false, filterable: false,
accessor: (row) => row.num_available_segments / row.num_segments, accessor: (row) => {
return {
num_available: row.num_available_segments,
num_total: row.num_segments
};
},
Cell: (row) => { Cell: (row) => {
const { datasource, num_available_segments, num_segments, disabled } = row.original; const { datasource, num_available_segments, num_segments, disabled } = row.original;
@ -415,6 +420,11 @@ GROUP BY 1`);
} }
}, },
sortMethod: (d1, d2) => {
const percentAvailable1 = d1.num_available / d1.num_total;
const percentAvailable2 = d2.num_available / d2.num_total;
return (percentAvailable1 - percentAvailable2) || (d1.num_total - d2.num_total);
},
show: tableColumnSelectionHandler.showColumn('Availability') show: tableColumnSelectionHandler.showColumn('Availability')
}, },
{ {