Skip to content

Commit 567a1d9

Browse files
Merge pull request #2395 from spadgett/events-sort
Automatic merge from submit-queue. Add resourceVersion as a secondary sort for events Fixes #1846 /assign @jwforres
2 parents c99ed2a + 729769c commit 567a1d9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

app/scripts/directives/events.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ angular.module('openshiftConsole')
4343
$scope.sortConfig.isAscending = !(defaultIsReversed[currentID]);
4444
}
4545
var order = $scope.sortConfig.isAscending ? 'asc' : 'desc';
46-
sortedEvents = _.orderBy($scope.events, [sortID], [order]);
46+
// Use `metadata.resourceVersion` as a secondary sort so that the
47+
// sort is stable. In practice, this makes sure that the events with
48+
// the same `lastTimestamp` appear in the correct order since events
49+
// only have second granularity.
50+
sortedEvents = _.orderBy($scope.events, [sortID, 'metadata.resourceVersion'], [order, order]);
4751
};
4852

4953
var filterExpressions = [];

app/scripts/directives/notifications/notificationDrawerWrapper.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@
153153
};
154154

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

159163
var render = function() {

dist/scripts/scripts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9325,7 +9325,7 @@ lastTimestamp: !0
93259325
var t = _.get(e, "sortConfig.currentField.id", "lastTimestamp");
93269326
l !== t && (l = t, e.sortConfig.isAscending = !u[l]);
93279327
var n = e.sortConfig.isAscending ? "asc" : "desc";
9328-
c = _.orderBy(e.events, [ t ], [ n ]);
9328+
c = _.orderBy(e.events, [ t, "metadata.resourceVersion" ], [ n, n ]);
93299329
}, m = [], p = function() {
93309330
e.filterExpressions = m = a.generateKeywords(_.get(e, "filter.text"));
93319331
}, f = [ "reason", "message", "type" ];
@@ -14638,7 +14638,7 @@ return c.isImportantAPIEvent(t) && !c.isCleared(t.metadata.uid) && (e[t.metadata
1463814638
var n = r.project;
1463914639
return _.assign({}, e[n], t[n]);
1464014640
}, N = function(e) {
14641-
return _.orderBy(e, [ "event.lastTimestamp", "event.firstTimestamp" ], [ "desc", "desc" ]);
14641+
return _.orderBy(e, [ "event.lastTimestamp", "event.metadata.resourceVersion" ], [ "desc", "desc" ]);
1464214642
}, D = function() {
1464314643
o.$evalAsync(function() {
1464414644
p.notificationGroups = [ S(r.project, N(T(g, v))) ], k();

0 commit comments

Comments
 (0)