@zmnatz/usa-club-rugby-data 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,3 +35,11 @@ export declare function clubsInRows(rows: PlayerRow[]): Club[];
35
35
  * are combined into a single total; rows with no id cannot be joined and are
36
36
  * excluded. */
37
37
  export declare function computeBreakdown(rows: PlayerRow[], sides: Side[], rules: EligibilityRules, remaining?: RemainingMatches): EligibilityBreakdown;
38
+ /** Where a player stands on a side, most urgent first. */
39
+ export declare const VERDICT_STATUSES: readonly ['ineligible', 'caution', 'on-track', 'eligible'];
40
+ export type VerdictStatus = (typeof VERDICT_STATUSES)[number];
41
+ /** A verdict as one status. Ineligible outranks Caution, and Caution outranks On
42
+ * Track, which a player can still recover from. */
43
+ export declare function verdictStatus(player: Pick<PlayerEligibility, 'eligible' | 'pending' | 'cautions'>): VerdictStatus;
44
+ /** A status's place in `VERDICT_STATUSES`, for sorting: lowest is most urgent. */
45
+ export declare function verdictRank(player: Pick<PlayerEligibility, 'eligible' | 'pending' | 'cautions'>): number;
@@ -251,3 +251,18 @@ export function computeBreakdown(rows, sides, rules, remaining = {}) {
251
251
  ignoredTeamNames: [...new Set(rows.map((row) => row.teamName).filter((name) => !teamNames.has(name)))],
252
252
  };
253
253
  }
254
+ /** Where a player stands on a side, most urgent first. */
255
+ export const VERDICT_STATUSES = ['ineligible', 'caution', 'on-track', 'eligible'];
256
+ /** A verdict as one status. Ineligible outranks Caution, and Caution outranks On
257
+ * Track, which a player can still recover from. */
258
+ export function verdictStatus(player) {
259
+ if (!player.eligible)
260
+ return 'ineligible';
261
+ if (player.cautions.length > 0)
262
+ return 'caution';
263
+ return player.pending.length > 0 ? 'on-track' : 'eligible';
264
+ }
265
+ /** A status's place in `VERDICT_STATUSES`, for sorting: lowest is most urgent. */
266
+ export function verdictRank(player) {
267
+ return VERDICT_STATUSES.indexOf(verdictStatus(player));
268
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zmnatz/usa-club-rugby-data",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "USA Club Rugby senior club teams, players and NCS eligibility from the Rugby Xplorer match record: typed readers for the nightly published data, a rate-limited CMS client, and the reproducible eligibility rules.",
5
5
  "keywords": [
6
6
  "rugby",