fix: reduce load of simultaneous queries to kotahi server
Flax was making duplicate, unnecessary queries to Kotahi, and was running a lot of queries in parallel. This resulted in knex timeout errors on the Kotahi server and it was unable to properly respond to the queries, meaning that CMS publishing intermittently failed.
I've fixed this by:
- passing the result of
getCMSLayout
down through the calling tree, rather than re-querying it at multiple points - getting chunks of articles one chunk at a time, rather than all chunks in parallel (this would be a lot of simultaneous queries if there are a lot of published articles)
- Skipping an unnecessary preliminary query to determine the total number of articles (
totalCount
)