Closed adzialocha closed 2 years ago
So I think this is a Sequelize bug, they seem to have a bunch of issues when findAndCountAll is involved with, limits, counts, orders and offsets. I found one suggested solution which is to add a {subQuery: false} param to the findAndCountAll request.
the above would become this:
return Event.findAndCountAll({
distinct: true,
include: req.user.isVisitor ? includeForVisitors : include,
limit,
offset,
order: [
[EventHasManySlots, 'from', 'ASC'],
],
where: req.user.isVisitor ? { isPublic: true } : {},
subQuery:false,
})
I tried this locally and it seemed to work, but then when I pushed the fix to my antiuniversity branch a different problem came up where only two pages of events were being fetched but not the rest. They were in the correct order though....
Might be worth trying this fix, or I suggest just disabling pagination for the calendar page while we figure out the proper fix.
Clicking on the "Load More" button in the paginated calendar view results in loading new events which are not ordered correctly by time. Example:
Calendar displays:
A click on "Load more" results in: