Skip to content

Commit

Permalink
Merge pull request #2395 from spadgett/events-sort
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Add resourceVersion as a secondary sort for events

Fixes #1846

/assign @jwforres
  • Loading branch information
openshift-merge-robot authored Oct 30, 2017
2 parents c99ed2a + 729769c commit 567a1d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/scripts/directives/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ angular.module('openshiftConsole')
$scope.sortConfig.isAscending = !(defaultIsReversed[currentID]);
}
var order = $scope.sortConfig.isAscending ? 'asc' : 'desc';
sortedEvents = _.orderBy($scope.events, [sortID], [order]);
// Use `metadata.resourceVersion` as a secondary sort so that the
// sort is stable. In practice, this makes sure that the events with
// the same `lastTimestamp` appear in the correct order since events
// only have second granularity.
sortedEvents = _.orderBy($scope.events, [sortID, 'metadata.resourceVersion'], [order, order]);
};

var filterExpressions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@
};

var sortMap = function(map) {
return _.orderBy(map, ['event.lastTimestamp', 'event.firstTimestamp'], ['desc', 'desc']);
// Use `metadata.resourceVersion` as a secondary sort so that the sort
// is stable. In practice, this makes sure that the events with the
// same `lastTimestamp` appear in the correct order since events only
// have second granularity.
return _.orderBy(map, ['event.lastTimestamp', 'event.metadata.resourceVersion'], ['desc', 'desc']);
};

var render = function() {
Expand Down
4 changes: 2 additions & 2 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9325,7 +9325,7 @@ lastTimestamp: !0
var t = _.get(e, "sortConfig.currentField.id", "lastTimestamp");
l !== t && (l = t, e.sortConfig.isAscending = !u[l]);
var n = e.sortConfig.isAscending ? "asc" : "desc";
c = _.orderBy(e.events, [ t ], [ n ]);
c = _.orderBy(e.events, [ t, "metadata.resourceVersion" ], [ n, n ]);
}, m = [], p = function() {
e.filterExpressions = m = a.generateKeywords(_.get(e, "filter.text"));
}, f = [ "reason", "message", "type" ];
Expand Down Expand Up @@ -14638,7 +14638,7 @@ return c.isImportantAPIEvent(t) && !c.isCleared(t.metadata.uid) && (e[t.metadata
var n = r.project;
return _.assign({}, e[n], t[n]);
}, N = function(e) {
return _.orderBy(e, [ "event.lastTimestamp", "event.firstTimestamp" ], [ "desc", "desc" ]);
return _.orderBy(e, [ "event.lastTimestamp", "event.metadata.resourceVersion" ], [ "desc", "desc" ]);
}, D = function() {
o.$evalAsync(function() {
p.notificationGroups = [ S(r.project, N(T(g, v))) ], k();
Expand Down

0 comments on commit 567a1d9

Please sign in to comment.