mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 01:49:41 -05:00
Fetch projected inputs with an overflow sentinel before start or close, reject oversized card/list sets without partial snapshots, and index done-list membership once. Cover exact limits and unchanged lifecycle/History on rejection with unit and Chromium tests. Thanks to xet7 !
20 lines
970 B
JavaScript
20 lines
970 B
JavaScript
const { SCRUM_SNAPSHOT_LIMIT } = require('../../models/lib/scrum');
|
|
|
|
// Fetch one sentinel beyond the snapshot limit so the snapshot validator can
|
|
// reject incomplete input before any lifecycle/History writes. Exclude large
|
|
// unrelated card bodies and attachments, retaining rollover preconditions.
|
|
async function loadScrumSnapshotInputs({ cards, lists, boardId, sprintId, includeArchived }) {
|
|
const [cardRows, listRows] = await Promise.all([
|
|
cards.find({ boardId, 'scrum.sprintId': sprintId,
|
|
...(includeArchived ? {} : { archived: { $ne: true } }) }, {
|
|
limit: SCRUM_SNAPSHOT_LIMIT + 1,
|
|
fields: { listId: 1, archived: 1, dueComplete: 1, 'poker.estimation': 1,
|
|
customFields: 1, scrum: 1, scrumRevision: 1 },
|
|
}).fetchAsync(),
|
|
lists.find({ boardId }, { limit: SCRUM_SNAPSHOT_LIMIT + 1,
|
|
fields: { scrum: 1 } }).fetchAsync(),
|
|
]);
|
|
return { cards: cardRows, lists: listRows };
|
|
}
|
|
module.exports = { loadScrumSnapshotInputs };
|