rule

package
v0.30.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rule

type Rule struct {
	ID         string `json:"id"`
	ScheduleID string `json:"schedule_id"`
	timeutil.WeekdayFilter
	Start     timeutil.Clock `json:"start"`
	End       timeutil.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

func (r Rule) AlwaysActive() bool

AlwaysActive will return true if the rule will always be active.

func (Rule) EndTime

func (r Rule) EndTime(t time.Time) time.Time

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.

If the rule is always active, or never active, it returns a zero time.

func (Rule) IsActive

func (r Rule) IsActive(t time.Time) bool

IsActive determines if the rule is active in the given moment in time, in the location of t.

func (Rule) NeverActive

func (r Rule) NeverActive() bool

NeverActive returns true if the rule will never be active.

func (Rule) Normalize

func (r Rule) Normalize() (*Rule, error)

func (Rule) StartTime

func (r Rule) StartTime(t time.Time) time.Time

StartTime will return the next time the rule would be active. If the rule is currently active, it will return the time it became active (in the past).

If the rule is NeverActive or AlwaysActive, zero time is returned.

It may break when processing a timezone where daylight savings repeats or skips ahead at midnight.

func (Rule) String

func (r Rule) String() string

String returns a human-readable string describing the rule

type ScheduleTriggerFunc

type ScheduleTriggerFunc func(string)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore added in v0.30.0

func NewStore(ctx context.Context, db *sql.DB) (*Store, error)

func (*Store) Add

func (s *Store) Add(ctx context.Context, r *Rule) (*Rule, error)

func (*Store) CreateRuleTx

func (s *Store) CreateRuleTx(ctx context.Context, tx *sql.Tx, r *Rule) (*Rule, error)

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, ruleID string) error

func (*Store) DeleteByTarget

func (s *Store) DeleteByTarget(ctx context.Context, scheduleID string, target assignment.Target) error

DeleteByTarget removes all rules for a schedule pointing to the specified target.

func (*Store) DeleteManyTx

func (s *Store) DeleteManyTx(ctx context.Context, tx *sql.Tx, ruleIDs []string) error

func (*Store) DeleteTx

func (s *Store) DeleteTx(ctx context.Context, tx *sql.Tx, ruleID string) error

func (*Store) FindAll added in v0.30.0

func (s *Store) FindAll(ctx context.Context, scheduleID string) ([]Rule, error)

func (*Store) FindAllTx added in v0.30.0

func (s *Store) FindAllTx(ctx context.Context, tx *sql.Tx, scheduleID string) ([]Rule, error)

func (*Store) FindAllWithUsers added in v0.30.0

func (s *Store) FindAllWithUsers(ctx context.Context, 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.

func (*Store) FindByTargetTx

func (s *Store) FindByTargetTx(ctx context.Context, tx *sql.Tx, scheduleID string, target assignment.Target) ([]Rule, error)

func (*Store) FindOne added in v0.30.0

func (s *Store) FindOne(ctx context.Context, ruleID string) (*Rule, error)

func (*Store) FindScheduleID added in v0.30.0

func (s *Store) FindScheduleID(ctx context.Context, ruleID string) (string, error)

func (*Store) Update

func (s *Store) Update(ctx context.Context, r *Rule) error

func (*Store) UpdateTx

func (s *Store) UpdateTx(ctx context.Context, tx *sql.Tx, r *Rule) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL