Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resourceVersion as a secondary sort for events #2395

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
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