Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(clientsConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return clientsConnection;
}
return {
...clientsConnection,
edges: [...clientsConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
(cachePurgesConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return cachePurgesConnection;
}
return {
...cachePurgesConnection,
edges: [...cachePurgesConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
(rolesConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return rolesConnection;
}
return {
...rolesConnection,
edges: [...rolesConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
(cachePurgesConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return cachePurgesConnection;
}
return {
...cachePurgesConnection,
edges: [...cachePurgesConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
Object.entries(healthSummary).forEach(([key, item]) => {
healthSummary[key].healthy =
or0(item.successful) + or0(item.cleanShutdown) + or0(item.running);
healthSummary[key].unhealthy =
or0(item.failed) +
or0(item.spotKill) +
or0(item.insufficientCapacity) +
or0(item.volumeLimitExceeded) +
or0(item.missingAmi) +
or0(item.startupFailed) +
or0(item.unknownCodes) +
or0(item.noCode);
});
const sortByProperty = camelCase(sortBy);
const healthValues = Object.values(healthSummary);
if (!sortBy || isEmpty(healthValues)) {
return healthValues;
}
return healthValues.sort((a, b) => {
const firstElement =
sortDirection === 'desc' ? b[sortByProperty] : a[sortByProperty];
const secondElement =
sortDirection === 'desc' ? a[sortByProperty] : b[sortByProperty];
return sort(firstElement, secondElement);
});
},
{
(rolesConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return rolesConnection;
}
return {
...rolesConnection,
edges: [...rolesConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
(clientsConnection, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!sortBy) {
return clientsConnection;
}
return {
...clientsConnection,
edges: [...clientsConnection.edges].sort((a, b) => {
const firstElement =
sortDirection === 'desc'
? b.node[sortByProperty]
: a.node[sortByProperty];
const secondElement =
sortDirection === 'desc'
? a.node[sortByProperty]
: b.node[sortByProperty];
(workerTypes, sortBy, sortDirection, searchTerm) => {
const sortByProperty = camelCase(sortBy);
const filteredWorkerTypes = searchTerm
? workerTypes.filter(({ workerType }) =>
workerType.includes(searchTerm)
)
: workerTypes;
return isEmpty(filteredWorkerTypes)
? filteredWorkerTypes
: [...filteredWorkerTypes].sort((a, b) => {
const firstElement =
sortDirection === 'desc' ? b[sortByProperty] : a[sortByProperty];
const secondElement =
sortDirection === 'desc' ? a[sortByProperty] : b[sortByProperty];
return sort(firstElement, secondElement);
});
(errors, sortBy, sortDirection) => {
const sortByProperty = camelCase(sortBy);
if (!errors) {
return null;
}
return [...errors].sort((a, b) => {
const firstElement =
sortDirection === 'desc' ? b[sortByProperty] : a[sortByProperty];
const secondElement =
sortDirection === 'desc' ? a[sortByProperty] : b[sortByProperty];
if (sortByProperty === 'type') {
return sort(
this.getErrorType(firstElement),
this.getErrorType(secondElement)
);