feat(stats): show work and time-off lengths (#66)
This commit is contained in:
1 parent
d9f3f8d34a
commit
3fbf9c3172
12 files changed
+373
-20
No files matched your search
@@ -460,6 +460,9 @@ export interface PlanningMetrics {
|
||||
holidayWeekValue: number;
|
||||
nonWorkingDayGain: number;
|
||||
longestWorkSequence: number;
|
||||
averageWorkSequence: number | null;
|
||||
averageTimeOffPeriod: number | null;
|
||||
longestTimeOffPeriod: number | null;
|
||||
shortSequenceDeficit: number;
|
||||
supportingPlacements: number;
|
||||
preferenceSatisfaction: number[];
|
||||
@@ -5026,6 +5029,7 @@ function qualityMetrics(
|
||||
} else current++;
|
||||
}
|
||||
if (context.workingDays.length) sequences.push(current);
|
||||
const nonEmptySequences = sequences.filter((length) => length > 0);
|
||||
const internal = hasTimeOff ? sequences.slice(1, -1) : [];
|
||||
const shortSequenceDeficit = internal.reduce(
|
||||
(sum, length) => sum + (length > 0 && length < 5 ? 5 - length : 0),
|
||||
@@ -5036,6 +5040,15 @@ function qualityMetrics(
|
||||
holidayWeekValue: holidayWeekValue(state, context),
|
||||
nonWorkingDayGain: periods.reduce((sum, period) => sum + period.nonWorkingDayGain, 0),
|
||||
longestWorkSequence: sequences.length ? Math.max(...sequences) : 0,
|
||||
averageWorkSequence: nonEmptySequences.length
|
||||
? nonEmptySequences.reduce((sum, length) => sum + length, 0) / nonEmptySequences.length
|
||||
: null,
|
||||
averageTimeOffPeriod: periods.length
|
||||
? periods.reduce((sum, period) => sum + period.duration, 0) / periods.length
|
||||
: null,
|
||||
longestTimeOffPeriod: periods.length
|
||||
? Math.max(...periods.map((period) => period.duration))
|
||||
: null,
|
||||
shortSequenceDeficit,
|
||||
supportingPlacements: [...state.placements.values()].filter(
|
||||
(placement) => placement.supporting,
|
||||
|
||||
Reference in new issue
Block a user