Skip to content

OccurrenceCapRule

A cap on how many local periods hold a status: “night duty no more often than every third night”, “duty started on at most 6 of any 7 days”.

import type { OccurrenceCapRule } from "@northguild/gmt";
MemberTypeDescription
labelstringThe caller’s name for the rule. The report is keyed by it; labels must be unique.
severity?"violation" | "advisory" (DutySeverity)Whether a failure is a violation or an advisory.
kind"occurrenceCap"Selects this rule kind.
statusesS[]The statuses that occur.
perLocalPeriodThe local period occurrences are counted by.
lookbacknumberHow many periods the window covers, an integer from 1 to 10,000. Times the count in per, it is 10,000 at most.
maximumnumberThe most periods allowed to hold an occurrence, a non-negative integer.
byInitiationDate?booleanWhether a run counts only in the period it starts in, so that two tours starting on one date count once and a night shift counts on the date it began.
type OccurrenceCapRule<S extends string = string> = {
/** The caller's name for the rule. The report is keyed by it; labels must be unique. */
label: string;
/**
* Whether a failure is a violation or an advisory.
*
* @defaultValue `"violation"`.
*/
severity?: DutySeverity;
/** Selects this rule kind. */
kind: "occurrenceCap";
/** The statuses that occur. */
statuses: S[];
/** The local period occurrences are counted by. */
per: LocalPeriod;
/**
* How many periods the window covers, an integer from 1 to 10,000. Times the count in `per`, it
* is 10,000 at most.
*/
lookback: number;
/** The most periods allowed to hold an occurrence, a non-negative integer. */
maximum: number;
/**
* Whether a run counts only in the period it starts in, so that two tours starting on one date
* count once and a night shift counts on the date it began.
*
* @defaultValue `false`. A run counts in every period it touches.
*/
byInitiationDate?: boolean;
};

types/duty.ts