Files
wekan/server/lib/dueDateEdits.js
T
Lauri OjansivuandClaude Opus 4.8 a8ed326a5b Add #6081: show how many times a card's due date was changed
Display a 'due date changed N times' count on the card detail (derived from
existing a-dueAt activities via getDueDateChangeCount) for deadline
accountability. Counting logic extracted to server/lib/dueDateEdits.js with
unit tests. MVP per the issue (display rather than hard limit).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 14:38:50 +03:00

22 lines
869 B
JavaScript

// Pure helpers for counting due-date changes (issue #6081).
//
// WeKan records a due-date change as an Activity with
// `activityType === 'a-dueAt'` (see server/models/cards.js before.update hook).
// Counting those activities for a card gives the number of times the due date
// was set or changed, which lets a Scrum Master see deadline movement without
// being able to quietly move it.
export const DUE_DATE_ACTIVITY_TYPE = 'a-dueAt';
// Count how many of the given activities represent a due-date change.
// `activities` is expected to be an array of activity documents (or any
// array-like with a `.filter`); anything falsy yields 0.
export function countDueDateChanges(activities) {
if (!Array.isArray(activities)) {
return 0;
}
return activities.filter(
activity => activity && activity.activityType === DUE_DATE_ACTIVITY_TYPE,
).length;
}