Skip to content

Commit

Permalink
Bug 1413156 - lodash to ES6: replace _.some, _.keys in PerfHerder (#3374
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Dottori authored and Cameron Dawson committed Mar 27, 2018
1 parent cc7411e commit 9c01728
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ui/js/components/perf/compare.js
Expand Up @@ -77,7 +77,7 @@ treeherder.component('phCompareTable', {
ctrl.filteredResultList[key] = compareResults;
}
});
ctrl.filteredResultList = _.map(_.keys(ctrl.filteredResultList), function (testName) {
ctrl.filteredResultList = _.map(Object.keys(ctrl.filteredResultList), function (testName) {
return { testName: testName, results: ctrl.filteredResultList[testName] };
});
};
Expand Down
2 changes: 1 addition & 1 deletion ui/js/controllers/filters.js
Expand Up @@ -63,7 +63,7 @@ treeherderApp.controller('JobFilterCtrl', [
*/
$scope.toggleResultStatusFilterChicklet = function (filter) {
let filterValues;
if (_.keys($scope.filterGroups).indexOf(filter) !== -1) {
if (Object.keys($scope.filterGroups).indexOf(filter) !== -1) {
// this is a filter grouping, so toggle all on/off
filterValues = $scope.filterGroups[filter].resultStatuses;
} else {
Expand Down
13 changes: 5 additions & 8 deletions ui/js/controllers/perf/alerts.js
Expand Up @@ -208,8 +208,7 @@ perf.controller('AlertsCtrl', [
// reset alert's selected status if it is no longer visible
alert.selected = alert.selected && alert.visible;
});
alertSummary.anyVisible = _.some(alertSummary.alerts,
'visible');
alertSummary.anyVisible = alertSummary.alerts.map(x => x.visible).some(x => x);

// if all are selected with this alert summary, update which
// ones are selected
Expand All @@ -224,12 +223,10 @@ perf.controller('AlertsCtrl', [
// these methods handle the business logic of alert selection and
// unselection
$scope.anySelected = function (alerts) {
return _.some(_.map(alerts, 'selected'));
return alerts.map(alert => alert.selected).some(x => x);
};
$scope.anySelectedAndTriaged = function (alerts) {
return _.some(alerts, function (alert) {
return (!alert.isUntriaged() && alert.selected);
});
return alerts.map(alert => !alert.isUntriaged() && alert.selected).some(x => x);
};
$scope.selectNoneOrSelectAll = function (alertSummary) {
// if some are not selected, then select all if checked
Expand Down Expand Up @@ -389,9 +386,9 @@ perf.controller('AlertsCtrl', [
});
});

$q.all(_.map(_.keys(resultSetToSummaryMap), function (repo) {
$q.all(_.map(Object.keys(resultSetToSummaryMap), function (repo) {
return ThResultSetModel.getResultSetList(
repo, _.keys(resultSetToSummaryMap[repo]), true).then(
repo, Object.keys(resultSetToSummaryMap[repo]), true).then(
function (response) {
response.data.results.forEach(function (resultSet) {
resultSet.dateStr = dateFilter(
Expand Down
15 changes: 7 additions & 8 deletions ui/js/controllers/perf/graphs.js
Expand Up @@ -970,10 +970,9 @@ perf.controller('TestChooserCtrl', ['$scope', '$uibModalInstance',
$scope.testsToAdd = _.clone(seriesList.filter(series =>
series.platform !== originalSeries.platform &&
series.name === originalSeries.name &&
!_.some(testsDisplayed, {
projectName: series.projectName,
signature: series.signature
})
!testsDisplayed.map(test =>
(test.projectName === series.projectName &&
test.signature === series.signature)).some(x => x)
));
}).then(function () {
// resolve the testsToAdd's length after every thing was done
Expand Down Expand Up @@ -1003,10 +1002,10 @@ perf.controller('TestChooserCtrl', ['$scope', '$uibModalInstance',
seriesList = _.flatten(seriesList);

// filter out tests which are already displayed
$scope.testsToAdd = seriesList.filter(series => !_.some(testsDisplayed, {
projectName: series.projectName,
signature: series.signature
}));
$scope.testsToAdd = seriesList.filter(series =>
!testsDisplayed.map(test =>
(test.projectName === series.projectName &&
test.signature === series.signature)).some(x => x));
}).then(function () {
loadingExtraDataPromise.resolve($scope.testsToAdd.length);
});
Expand Down
2 changes: 1 addition & 1 deletion ui/js/models/repository.js
Expand Up @@ -274,7 +274,7 @@ treeherder.factory('ThRepositoryModel', [
setCurrent(options.name);
}
if (options.watchRepos) {
if (_.isArray(storedWatched)) {
if (Array.isArray(storedWatched)) {

// To get the current repo to display first, we must
// ensure it's added to the array last, as per normal user interaction
Expand Down

0 comments on commit 9c01728

Please sign in to comment.