mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
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>
22 lines
869 B
JavaScript
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;
|
|
}
|