Skip to content

Commit ede8b6e

Browse files
committed
Enforce event ordering
**WILL BREAK THE UI WITHOUT THE REQUIRED BACKEND CHANGES:** opencast/opencast#6461 The events table is sorted by a sort parameter. By default, this is the start date. If there are multiple events with the same start date, the sorting for those is left to the elasticseach index in the backend. Elasticsearch however does not guarantee any ordering. This may result in the order of events changing unexpectedly like in #1102. This patch aims to solve this by adding a secondary sort parameter to the events query. The primary parameter still takes priority. For the secondary parameter, `uid` was chosen as it is the only field guaranteed to be unique. More sorting parameters can lead to increased query times. If someone with *many* events could test the impact of these changes that would be great.
1 parent fe113d7 commit ede8b6e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/slices/eventSlice.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ export const fetchEvents = createAppAsyncThunk('events/fetchEvents', async (_, {
232232
const state = getState();
233233
let params: ReturnType<typeof getURLParams> & { getComments?: boolean } = getURLParams(state);
234234

235+
// Add a secondary filter to enforce order of events
236+
// (Elasticsearch does not guarantee ordering)
237+
params = {
238+
...params,
239+
sort: params.sort ? params.sort + ",uid:asc" : "uid:asc"
240+
}
241+
235242
// Only if the notes column is enabled, fetch comment information for events
236243
if (state.table.columns.find(column => column.label === "EVENTS.EVENTS.TABLE.ADMINUI_NOTES" && !column.deactivated)) {
237244
params = {

0 commit comments

Comments
 (0)