Files
wekan/server/lib/scrumSnapshotInputs.js
T
Lauri Ojansivu 429c360bad Bound Scrum lifecycle snapshot reads and completion lookup cost
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 !
2026-09-28 01:10:38 +03:00

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 };