Documentation
¶
Index ¶
- type Clock
- type DB
- func (db *DB) Add(ctx context.Context, r *Rule) (*Rule, error)
- func (db *DB) CreateRuleTx(ctx context.Context, tx *sql.Tx, r *Rule) (*Rule, error)
- func (db *DB) Delete(ctx context.Context, ruleID string) error
- func (db *DB) DeleteByTarget(ctx context.Context, scheduleID string, target assignment.Target) error
- func (db *DB) DeleteManyTx(ctx context.Context, tx *sql.Tx, ruleIDs []string) error
- func (db *DB) DeleteTx(ctx context.Context, tx *sql.Tx, ruleID string) error
- func (db *DB) FindAll(ctx context.Context, scheduleID string) ([]Rule, error)
- func (db *DB) FindAllTx(ctx context.Context, tx *sql.Tx, scheduleID string) ([]Rule, error)
- func (db *DB) FindAllWithUsers(ctx context.Context, scheduleID string) ([]Rule, error)
- func (db *DB) FindByTargetTx(ctx context.Context, tx *sql.Tx, scheduleID string, target assignment.Target) ([]Rule, error)
- func (db *DB) FindOne(ctx context.Context, ruleID string) (*Rule, error)
- func (db *DB) FindScheduleID(ctx context.Context, ruleID string) (string, error)
- func (db *DB) Update(ctx context.Context, r *Rule) error
- func (db *DB) UpdateTx(ctx context.Context, tx *sql.Tx, r *Rule) error
- type ReadStore
- type Rule
- type ScheduleTriggerFunc
- type Store
- type WeekdayFilter
- func (f WeekdayFilter) Day(d time.Weekday) bool
- func (f WeekdayFilter) DaysSince(d time.Weekday, enabled bool) int
- func (f WeekdayFilter) DaysUntil(d time.Weekday, enabled bool) int
- func (f *WeekdayFilter) SetDay(d time.Weekday, enabled bool)
- func (f WeekdayFilter) String() string
- func (f WeekdayFilter) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock represents wall-clock time. It is a duration since midnight.
func ParseClock ¶
ParseClock will return a new Clock value given a value in the format of '15:04' or '15:04:05'. The resulting value will be truncated to the minute.
func (Clock) Format ¶
Format will format the clock value using the same format string used by time.Time.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CreateRuleTx ¶
func (*DB) DeleteByTarget ¶
func (db *DB) DeleteByTarget(ctx context.Context, scheduleID string, target assignment.Target) error
DeleteByTarget removes all rules for a schedule pointing to the specified target.
func (*DB) DeleteManyTx ¶
func (*DB) FindAllWithUsers ¶
func (*DB) FindByTargetTx ¶
func (*DB) FindScheduleID ¶
type ReadStore ¶
type ReadStore interface { FindScheduleID(context.Context, string) (string, error) FindOne(context.Context, string) (*Rule, error) FindAll(ctx context.Context, scheduleID string) ([]Rule, error) FindAllTx(ctx context.Context, tx *sql.Tx, scheduleID string) ([]Rule, error) // FindAllWithUsers works like FindAll but resolves rotations to the active user. // This is reflected in the Target attribute. // Rules pointing to inactive rotations (no participants) are omitted. FindAllWithUsers(ctx context.Context, scheduleID string) ([]Rule, error) }
type Rule ¶
type Rule struct { ID string `json:"id"` ScheduleID string `json:"schedule_id"` WeekdayFilter Start Clock `json:"start"` End Clock `json:"end"` CreatedAt time.Time `json:"created_at"` Target assignment.Target }
func NewAlwaysActive ¶
func NewAlwaysActive(scheduleID string, tgt assignment.Target) *Rule
func (Rule) AlwaysActive ¶
AlwaysActive will return true if the rule will always be active.
func (Rule) EndTime ¶
EndTime will return the next time the rule would be inactive. If the rule is currently inactive, it will return the end of the next shift.
func (Rule) IsActive ¶
IsActive determines if the rule is active in the given moment in time, in the location of t.
func (Rule) NeverActive ¶
NeverActive returns true if the rule will never be active.
type ScheduleTriggerFunc ¶
type ScheduleTriggerFunc func(string)
type Store ¶
type Store interface { ReadStore Add(context.Context, *Rule) (*Rule, error) CreateRuleTx(context.Context, *sql.Tx, *Rule) (*Rule, error) Update(context.Context, *Rule) error UpdateTx(context.Context, *sql.Tx, *Rule) error Delete(context.Context, string) error DeleteTx(context.Context, *sql.Tx, string) error DeleteManyTx(context.Context, *sql.Tx, []string) error DeleteByTarget(ctx context.Context, scheduleID string, target assignment.Target) error FindByTargetTx(ctx context.Context, tx *sql.Tx, scheduleID string, target assignment.Target) ([]Rule, error) }
type WeekdayFilter ¶
type WeekdayFilter [7]byte
func (WeekdayFilter) Day ¶
func (f WeekdayFilter) Day(d time.Weekday) bool
Day will return true if the given weekday is enabled.
func (WeekdayFilter) DaysSince ¶
func (f WeekdayFilter) DaysSince(d time.Weekday, enabled bool) int
DaysSince will give the number of days since an enabled day from the given weekday. -1 is returned if all days are disabled.
func (WeekdayFilter) DaysUntil ¶
func (f WeekdayFilter) DaysUntil(d time.Weekday, enabled bool) int
DaysUntil will give the number of days until a matching day from the given weekday. -1 is returned if no days match.
func (*WeekdayFilter) SetDay ¶
func (f *WeekdayFilter) SetDay(d time.Weekday, enabled bool)
SetDay will update the filter for the given weekday.
func (WeekdayFilter) String ¶
func (f WeekdayFilter) String() string
String returns a string representation of the WeekdayFilter.