rotation

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoState = errors.New("no state available")

ErrNoState is returned when there is no state information available for a rotation.

Functions

This section is empty.

Types

type Participant

type Participant struct {
	ID         string `json:"id"`
	Position   int    `json:"position"`
	RotationID string `json:"rotation_id"`
	Target     assignment.Target
}

func (Participant) Normalize

func (p Participant) Normalize() (*Participant, error)

type Rotation

type Rotation struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`

	Type        Type      `json:"type"`
	Start       time.Time `json:"start"`
	ShiftLength int       `json:"shift_length"`
	// contains filtered or unexported fields
}

func (Rotation) EndTime

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

EndTime calculates the end of the "shift" that started at (or was active) at t.

It is guaranteed to occur after t.

func (Rotation) IsUserFavorite added in v0.23.0

func (r Rotation) IsUserFavorite() bool

func (Rotation) Normalize

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

func (Rotation) StartTime

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

StartTime calculates the start of the "shift" that started at (or was active) at t. For daily and weekly rotations, start time will be the previous handoff time (from start).

type SearchCursor

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

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

type SearchOptions

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

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

	Limit int `json:"-"`

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

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

	//FavoritesUserID is the userID associated with the rotation favorite
	FavoritesUserID string `json:"u,omitempty"`
}

SearchOptions allow filtering and paginating the list of rotations.

type State

type State struct {
	RotationID    string
	ParticipantID string
	Position      int
	ShiftStart    time.Time
}

func (State) Normalize

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

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) AddParticipant

func (s *Store) AddParticipant(ctx context.Context, p *Participant) (*Participant, error)

func (*Store) AddParticipantTx

func (s *Store) AddParticipantTx(ctx context.Context, tx *sql.Tx, p *Participant) (*Participant, error)

func (*Store) AddRotationUsersTx

func (s *Store) AddRotationUsersTx(ctx context.Context, tx *sql.Tx, rotationID string, userIDs []string) error

func (*Store) CreateRotation

func (s *Store) CreateRotation(ctx context.Context, r *Rotation) (*Rotation, error)

func (*Store) CreateRotationTx

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

func (*Store) DeleteManyTx

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

func (*Store) DeleteRotation

func (s *Store) DeleteRotation(ctx context.Context, id string) error

func (*Store) DeleteRotationParticipantsTx

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

func (*Store) DeleteRotationTx

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

func (*Store) DeleteStateTx

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

func (*Store) FindAllParticipants added in v0.30.0

func (s *Store) FindAllParticipants(ctx context.Context, rotationID string) ([]Participant, error)

func (*Store) FindAllParticipantsByScheduleID added in v0.30.0

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

func (*Store) FindAllParticipantsTx added in v0.30.0

func (s *Store) FindAllParticipantsTx(ctx context.Context, tx *sql.Tx, rotationID string) ([]Participant, error)

func (*Store) FindAllRotations added in v0.30.0

func (s *Store) FindAllRotations(ctx context.Context) ([]Rotation, error)

func (*Store) FindAllRotationsByScheduleID added in v0.30.0

func (s *Store) FindAllRotationsByScheduleID(ctx context.Context, schedID string) ([]Rotation, error)

func (*Store) FindAllStateByScheduleID added in v0.30.0

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

func (*Store) FindMany

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

func (*Store) FindParticipant added in v0.30.0

func (s *Store) FindParticipant(ctx context.Context, id string) (*Participant, error)

func (*Store) FindParticipantCount added in v0.30.0

func (s *Store) FindParticipantCount(ctx context.Context, id string) (int, error)

func (*Store) FindRotation added in v0.30.0

func (s *Store) FindRotation(ctx context.Context, id string) (*Rotation, error)

func (*Store) FindRotationForUpdateTx added in v0.30.0

func (s *Store) FindRotationForUpdateTx(ctx context.Context, tx *sql.Tx, rotationID string) (*Rotation, error)

func (*Store) IsParticipantActive

func (s *Store) IsParticipantActive(ctx context.Context, partID string) (bool, error)

func (*Store) MoveParticipant

func (s *Store) MoveParticipant(ctx context.Context, id string, newPos int) error

func (*Store) RemoveParticipant

func (s *Store) RemoveParticipant(ctx context.Context, id string) (string, error)

func (*Store) RemoveParticipantTx

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

func (*Store) Search

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

func (*Store) SetActiveIndexTx

func (s *Store) SetActiveIndexTx(ctx context.Context, tx *sql.Tx, rotID string, position int) error

func (*Store) SetActiveParticipant

func (s *Store) SetActiveParticipant(ctx context.Context, rotID string, partID string) error

func (*Store) State added in v0.30.0

func (s *Store) State(ctx context.Context, id string) (*State, error)

func (*Store) StateTx added in v0.30.0

func (s *Store) StateTx(ctx context.Context, tx *sql.Tx, id string) (*State, error)

func (*Store) UpdateParticipantUserIDTx

func (s *Store) UpdateParticipantUserIDTx(ctx context.Context, tx *sql.Tx, partID, userID string) error

func (*Store) UpdateRotation

func (s *Store) UpdateRotation(ctx context.Context, r *Rotation) error

func (*Store) UpdateRotationTx

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

type Type

type Type string
const (
	TypeWeekly Type = "weekly"
	TypeDaily  Type = "daily"
	TypeHourly Type = "hourly"
)

func (Type) MarshalGQL

func (t Type) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Type) Scan

func (r *Type) Scan(value interface{}) error

Scan handles reading a Role from the DB format

func (*Type) UnmarshalGQL

func (t *Type) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Marshaler interface

func (Type) Value

func (r Type) Value() (driver.Value, error)

Value converts the Role to the DB representation

Jump to

Keyboard shortcuts

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