...
View file | ||
---|---|---|
|
View file | ||
---|---|---|
|
...
Models
Currently suspensions are hardcoded since Baseball and Soccer rules are fairly simple, but since Hockey is dependent on penalty codes, we’ll need to add this to the rulebook.
Sanction
Suspensions are linked to a sanction to describe what the suspension is for
...
Property
...
Type
...
Description
...
id
...
uuid
...
seasonId
...
string
...
Season
...
name
...
string
...
With i18n
...
code
...
string
...
Usually the rule number or an accumulation code
...
durationType
...
enum
...
Definite or Indefinite
...
officeId
...
number
...
1:1 with the rulebook office
...
externalId
...
uuid
...
For syncing with Spordle ID
Rulebook
In the future, we may split out rulebooks into multiple tables, but at this time, this would take too long to ship unhardcoded suspensions in time.
Note |
---|
May be worthwhile to implement changes to the rulebook (especially for infractions) prior to proceeding with suspension implementation, as linking with infraction IDs would simplify a lot |
SanctionRule
Will work similar to AssignRule matchers.
Minimum sanctions will be defined in the federation and each branch
Games will resolve sanctions from all parent rulebooks, children will cancel out parents based on matchers
Rulebook validation will require sanctions that match a parent rulebook to be at minimum of the parent
Still need to define how to cancel out yellow accumulation for indirect reds in soccer
Infractions are the rules, penalties are violations of infractions, sanctions define infraction accumulation and suspensions are the violation of sanctions.
SanctionRules act as sets of infractions and accumulation sets that produce a suspension with a given sanction.
SanctionRule
https://docs.google.com/spreadsheets/d/1iz1YxqmLZZsR02LOdJ8w3UkFT5noUtakCh_vjYMyAtM/edit#gid=0
Property | Type | Description |
---|---|---|
id | uuid |
Automatically generated
name | string | Description of the sanction rule |
positions | enum[] | Optional - Applicable to players or coaches |
Penalty matching
matchers[]
object[]
Types of penalties
name
string
Name of the penalty to match
code
string
Optional - code of the penalty to match
injury
boolean
Optional - accounts for if there’s a linked incident report with an injury or not
order | number | Rule precedence order |
sanctionId | uuid | Resulting sanction |
officeId | id | |
Accumulation | ||
order | number | Accumulation precedence order |
exclusive |
number
Optional - number of infractions to reset the count after
accumulations[]
object[]
Total number of infractions required to be accumulated
total
number
Optional? - Total number of infractions
sanctionId
uuid
Resulting sanction
Breaks
...
boolean | If an infraction matches this sanction it doesn’t count towards other sanctions | |
min | number | Minimum number of infractions (>=) |
max | number | Maximum number of infractions (<=) |
resets | boolean | Accumulation count resets to 0 after reaching last accumulation |
SanctionRuleMember
List of infractions that apply under a rule
Property | Type | Description |
---|---|---|
id | uuid |
startDate
date
endDate
date
Expiry Ratio
...
ruleId | id | |
infractionId | id | |
injury | boolean | Requires the penalty to be marked as injured |
Sanction
Suspensions are linked to a sanction to describe what the suspension is for
Property | Type | Description |
---|---|---|
id | uuid |
games
number
Optional - Number of games the accumulation requires
days
number
seasonId | string | Season |
name | string | With i18n |
code | string | Usually the rule number or an accumulation code |
durationType | enum | Definite or Indefinite |
officeId | number | |
externalId | uuid | For syncing with Spordle ID |
Suspension
Property | Type | Description | ||
---|---|---|---|---|
id | uuid | |||
gameId | id | Game the suspension originated in | ||
participantId | id | Participant that was suspended | ||
teamId | id | Team that the participant is suspended in | ||
positionGroup | enum | Position that this participant was suspended in. Player, Staff |
| enumDeprecated, replaced by |
sanctionId | sanctionId | id | Sanction that was determined by the rulebook sanction rules | |
penaltyId | id | Penalty that resulted in the suspension | ||
durationType | enum | Definite or Indefinite. This is required to be the same as the sanction duration | ||
minimumGames | number | Minimum number of games required for this suspension Optional when indefinite. Set by system. | ||
requiredGames | number | Number of games required to complete the suspension. Optional when Indefinite. Required to be >= minimumGames | ||
expiryDateexpiry | date | Optional - Date when the suspension will expire if the games requirement isn’t met | ||
status | enum | Pending, Appealed, Active, Completed, Cancelled, Expired | ||
externalId | uuid | For syncing with Spordle ID | ||
Legacy suspension options (deprecated) | ||||
| enum | Deprecated, replaced by sanctionId |
SanctionBreak
Required to define breaks when calculating the suspension expiry date for the season
Property | Type | Description |
---|---|---|
id | uuid | |
startDate | date | |
endDate | date | |
officeId | id |
SanctionRatio
BC Hockey defines a ratio generally, not per game, so it might be better to do the same. When games is undefined, it will serve as the default case and serve as a n:m ratio
Property | Type | Description |
---|---|---|
id | uuid | |
games | number | Optional - Number of games the accumulation requires |
days | number | Number of days |
officeId | id |
...
Implementation
Unhardcoding
Status | ||||
---|---|---|---|---|
|
...
When the game is completed (or certified, depending on settings), get all parent rulebooks of the schedule office
Cancel out sanctions in parent rulebooks that have a matching sanction in a child rulebook by matchers
Determine matching sanction rule for each player
Each penalty typically only results in one suspension per game
Hockey has some exceptions with accumulations and fighting
Determine sanction rules by matching the strictest penalty name/code match and order
TODO: indirect red will affect yellow here somehow 🚩
Get all past penalties and suspensions of all suspend-able players in the same season
In soccer, limit both to same office
Determine the sanction(s) based on the accumulation rules
accumulations[] is ordered, find the matching total based on the number of penalties incurred in past games and current. Account for reset count.If there are accumulated suspensions, they will be pending until the prior suspension has completed
7.2(c) results in 3 games, then later 7.8(c) will result in 3 games (15 days) immediately then AS107 5 games (25 days) following its completion
If there is an expiry ratio defined, calculate the expiry based on the number of days
If the expiry falls within a break, extend it by the number of days within that break
When creating the suspension, send a notification to the player, team officials and office admins (except player, will be based on notification setting)
...