schedule

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FixedShiftsPerTemporaryScheduleLimit = 150

FixedShiftsPerTemporaryScheduleLimit is the maximum number of shifts that can be configured for a single TemporarySchedule at a time.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data added in v0.27.0

type Data struct {
	V1 struct{ TemporarySchedules []TemporarySchedule }
}

Data contains configuration for a single schedule.

func (*Data) TempOnCall added in v0.27.0

func (data *Data) TempOnCall(t time.Time) (isActive bool, users []string)

TempOnCall will calculate any on-call users for the given time. isActive will be true if a temporary schedule is active.

type FixedShift added in v0.27.0

type FixedShift struct {
	Start, End time.Time
	UserID     string
}

A FixedShift represents an on-call user with a start and end time.

type Schedule

type Schedule struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	TimeZone    *time.Location `json:"time_zone"`
	// contains filtered or unexported fields
}

func (Schedule) IsUserFavorite added in v0.23.0

func (s Schedule) IsUserFavorite() bool

IsUserFavorite returns a boolean value based on if the schedule is a user favorite

func (Schedule) Normalize

func (s Schedule) Normalize() (*Schedule, error)

type SearchCursor

type SearchCursor struct {
	Name       string `json:"n,omitempty"`
	IsFavorite bool   `json:"f"`
}

SearchCursor is used to indicate a position in a paginated list.

type SearchOptions

type SearchOptions struct {
	Search string `json:"s,omitempty"`

	// FavoritesUserID specifies the UserID whose favorite services want to be displayed.
	FavoritesUserID string `json:"u,omitempty"`

	// FavoritesOnly controls filtering the results to those marked as favorites by FavoritesUserID.
	FavoritesOnly bool `json:"g,omitempty"`

	// FavoritesFirst indicates that services marked as favorite (by FavoritesUserID) should be returned first (before any non-favorites).
	FavoritesFirst bool `json:"f,omitempty"`

	After SearchCursor `json:"a,omitempty"`

	// Omit specifies a list of schedule IDs to exclude from the results.
	Omit []string `json:"o,omitempty"`

	Limit int `json:"-"`
}

SearchOptions allow filtering and paginating the list of schedules.

type Store

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

func NewStore added in v0.27.0

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

func (*Store) ClearTemporarySchedules added in v0.27.0

func (store *Store) ClearTemporarySchedules(ctx context.Context, tx *sql.Tx, scheduleID string, start, end time.Time) error

ClearTemporarySchedules will clear out (or split, if needed) any defined TemporarySchedules that exist between the start and end time.

func (*Store) Create

func (store *Store) Create(ctx context.Context, s *Schedule) (*Schedule, error)

func (*Store) CreateScheduleTx

func (store *Store) CreateScheduleTx(ctx context.Context, tx *sql.Tx, s *Schedule) (*Schedule, error)

func (*Store) Delete

func (store *Store) Delete(ctx context.Context, id string) error

func (*Store) DeleteManyTx

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

func (*Store) DeleteTx

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

func (*Store) FindAll added in v0.27.0

func (store *Store) FindAll(ctx context.Context) ([]Schedule, error)

func (*Store) FindMany

func (store *Store) FindMany(ctx context.Context, ids []string) ([]Schedule, error)

func (*Store) FindOne added in v0.27.0

func (store *Store) FindOne(ctx context.Context, id string) (*Schedule, error)

func (*Store) FindOneForUpdate

func (store *Store) FindOneForUpdate(ctx context.Context, tx *sql.Tx, id string) (*Schedule, error)

func (*Store) Search

func (store *Store) Search(ctx context.Context, opts *SearchOptions) ([]Schedule, error)

func (*Store) SetTemporarySchedule added in v0.27.0

func (store *Store) SetTemporarySchedule(ctx context.Context, tx *sql.Tx, scheduleID string, temp TemporarySchedule) error

SetTemporarySchedule will cause the schedule to use only, and exactly, the provided set of shifts between the provided start and end times.

func (*Store) TemporarySchedules added in v0.27.0

func (store *Store) TemporarySchedules(ctx context.Context, tx *sql.Tx, scheduleID string) ([]TemporarySchedule, error)

TemporarySchedules will return the current set for the provided scheduleID.

func (*Store) Update

func (store *Store) Update(ctx context.Context, s *Schedule) error

func (*Store) UpdateTx

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

type TemporarySchedule added in v0.27.0

type TemporarySchedule struct {
	Start, End time.Time
	Shifts     []FixedShift
}

TemporarySchedule represents a timespan containing static pre-defined shifts of on-call users.

func MergeTemporarySchedules added in v0.27.0

func MergeTemporarySchedules(tempScheds []TemporarySchedule) []TemporarySchedule

MergeTemporarySchedules will sort and merge TemporarySchedules and contained shifts

The output is guaranteed to be in-order and with no overlapping start/end times.

func (TemporarySchedule) TrimEnd added in v0.27.0

func (temp TemporarySchedule) TrimEnd(t time.Time) TemporarySchedule

TrimEnd will truncate and remove shifts so that the entire TemporarySchedule will end at the latest exactly t.

func (TemporarySchedule) TrimStart added in v0.27.0

func (temp TemporarySchedule) TrimStart(t time.Time) TemporarySchedule

TrimStart will truncate and remove shifts so that the entire TemporarySchedule will start at the earliest exactly t.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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