database

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShiftCollection          = "rosterd-shifts"
	RosterCollection         = "rosterd-rosters"
	OffTimeRequestCollection = "rosterd-offtime"
	OffTimeCostsCollection   = "rosterd-offtime-costs"
	ConstraintCollection     = "rosterd-constraints"
	WorktimeCollection       = "rosterd-worktime"
	DutyRosterCollection     = "rosterd-dutyrosters"
	RosterTypeCollection     = "rosterd-rostertypes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstraintDatabase

type ConstraintDatabase interface {
	CreateConstraint(ctx context.Context, req *structs.Constraint) error
	UpdateConstraint(ctx context.Context, constraint *structs.Constraint) error
	DeleteConstraint(ctx context.Context, id string) error
	FindConstraints(ctx context.Context, staff []string, roleIds []string) ([]structs.Constraint, error)
}

type DatabaseImpl

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

func NewDatabase

func NewDatabase(ctx context.Context, db *mongo.Database, logger *logrus.Entry) (*DatabaseImpl, error)

func (*DatabaseImpl) AddOffTimeCost

func (db *DatabaseImpl) AddOffTimeCost(ctx context.Context, costs *structs.OffTimeCosts) error

func (*DatabaseImpl) ApproveDutyRoster

func (db *DatabaseImpl) ApproveDutyRoster(ctx context.Context, rosterID string, approverID string) error

func (*DatabaseImpl) ApproveOffTimeRequest

func (db *DatabaseImpl) ApproveOffTimeRequest(ctx context.Context, id string, approval *structs.Approval) error

func (*DatabaseImpl) CreateConstraint

func (db *DatabaseImpl) CreateConstraint(ctx context.Context, constraint *structs.Constraint) error

func (*DatabaseImpl) CreateOffTimeRequest

func (db *DatabaseImpl) CreateOffTimeRequest(ctx context.Context, req *structs.OffTimeEntry) error

func (*DatabaseImpl) DeleteConstraint

func (db *DatabaseImpl) DeleteConstraint(ctx context.Context, id string) error

func (*DatabaseImpl) DeleteDutyRoster

func (db *DatabaseImpl) DeleteDutyRoster(ctx context.Context, id string, supersededBy primitive.ObjectID) error

func (*DatabaseImpl) DeleteOffTimeCosts

func (db *DatabaseImpl) DeleteOffTimeCosts(ctx context.Context, ids ...string) error

func (*DatabaseImpl) DeleteOffTimeCostsByRoster

func (db *DatabaseImpl) DeleteOffTimeCostsByRoster(ctx context.Context, rosterID string) error

func (*DatabaseImpl) DeleteOffTimeRequest

func (db *DatabaseImpl) DeleteOffTimeRequest(ctx context.Context, ids ...string) error

func (*DatabaseImpl) DeleteRosterType

func (db *DatabaseImpl) DeleteRosterType(ctx context.Context, rosterTypeName string) error

func (*DatabaseImpl) DeleteWorkShift

func (db *DatabaseImpl) DeleteWorkShift(ctx context.Context, id string) error

func (*DatabaseImpl) DeleteWorkTime

func (db *DatabaseImpl) DeleteWorkTime(ctx context.Context, ids ...string) error

func (*DatabaseImpl) DutyRosterByID

func (db *DatabaseImpl) DutyRosterByID(ctx context.Context, id string) (structs.DutyRoster, error)

func (*DatabaseImpl) DutyRostersByTime

func (db *DatabaseImpl) DutyRostersByTime(ctx context.Context, t time.Time) ([]structs.DutyRoster, error)

func (*DatabaseImpl) FindConstraints

func (db *DatabaseImpl) FindConstraints(ctx context.Context, staffs []string, roles []string) ([]structs.Constraint, error)

func (*DatabaseImpl) FindOffTimeRequests

func (db *DatabaseImpl) FindOffTimeRequests(ctx context.Context, from, to time.Time, approved *bool, staff []string) ([]structs.OffTimeEntry, error)

func (*DatabaseImpl) GetConstraintByID

func (db *DatabaseImpl) GetConstraintByID(ctx context.Context, id string) (*structs.Constraint, error)

func (*DatabaseImpl) GetCurrentWorkTimes

func (db *DatabaseImpl) GetCurrentWorkTimes(ctx context.Context, until time.Time) (map[string]structs.WorkTime, error)

func (*DatabaseImpl) GetOffTimeCosts

func (db *DatabaseImpl) GetOffTimeCosts(ctx context.Context, user_ids ...string) ([]structs.OffTimeCosts, error)

func (*DatabaseImpl) GetOffTimeRequest

func (db *DatabaseImpl) GetOffTimeRequest(ctx context.Context, ids ...string) ([]structs.OffTimeEntry, error)

func (*DatabaseImpl) GetRosterType

func (db *DatabaseImpl) GetRosterType(ctx context.Context, name string) (structs.RosterType, error)

func (*DatabaseImpl) GetRosterTypes

func (db *DatabaseImpl) GetRosterTypes(ctx context.Context) ([]structs.RosterType, error)

func (*DatabaseImpl) GetShiftsForDay

func (db *DatabaseImpl) GetShiftsForDay(ctx context.Context, weekDay time.Weekday, isHoliday bool) ([]structs.WorkShift, error)

func (*DatabaseImpl) GetSupersededDutyRoster

func (db *DatabaseImpl) GetSupersededDutyRoster(ctx context.Context, rosterID primitive.ObjectID) (*structs.DutyRoster, error)

func (*DatabaseImpl) GetWorktimeByID added in v1.2.0

func (db *DatabaseImpl) GetWorktimeByID(ctx context.Context, id string) (*structs.WorkTime, error)

func (*DatabaseImpl) ListWorkShifts

func (db *DatabaseImpl) ListWorkShifts(ctx context.Context) ([]structs.WorkShift, error)

func (*DatabaseImpl) LoadDutyRosters

func (db *DatabaseImpl) LoadDutyRosters(ctx context.Context) ([]structs.DutyRoster, error)

func (*DatabaseImpl) SaveDutyRoster

func (db *DatabaseImpl) SaveDutyRoster(ctx context.Context, roster *structs.DutyRoster) (bool, error)

func (*DatabaseImpl) SaveRosterType

func (db *DatabaseImpl) SaveRosterType(ctx context.Context, model structs.RosterType) error

func (*DatabaseImpl) SaveWorkShift

func (db *DatabaseImpl) SaveWorkShift(ctx context.Context, workShift *structs.WorkShift) error

func (*DatabaseImpl) SaveWorkTimePerWeek

func (db *DatabaseImpl) SaveWorkTimePerWeek(ctx context.Context, wt *structs.WorkTime) error

func (*DatabaseImpl) SetDebug

func (db *DatabaseImpl) SetDebug(v bool)

func (*DatabaseImpl) UpdateConstraint

func (db *DatabaseImpl) UpdateConstraint(ctx context.Context, constraint *structs.Constraint) error

func (*DatabaseImpl) UpdateOffTimeRequest added in v1.1.0

func (db *DatabaseImpl) UpdateOffTimeRequest(ctx context.Context, req *structs.OffTimeEntry) error

func (*DatabaseImpl) UpdateWorkTime added in v1.2.0

func (db *DatabaseImpl) UpdateWorkTime(ctx context.Context, wt *structs.WorkTime) error

func (*DatabaseImpl) WorkTimeHistoryForStaff

func (db *DatabaseImpl) WorkTimeHistoryForStaff(ctx context.Context, userID string) ([]structs.WorkTime, error)

type DutyRosterDatabase

type DutyRosterDatabase interface {
	SaveDutyRoster(ctx context.Context, roster *structs.DutyRoster) (bool, error)
	DeleteDutyRoster(ctx context.Context, rosterID string, supersededBy primitive.ObjectID) error
	ApproveDutyRoster(ctx context.Context, rosterID, approver string) error
	DutyRosterByID(ctx context.Context, id string) (structs.DutyRoster, error)
	DutyRostersByTime(ctx context.Context, time time.Time) ([]structs.DutyRoster, error)
	GetSupersededDutyRoster(ctx context.Context, rosterID primitive.ObjectID) (*structs.DutyRoster, error)
}

type OffTimeDatabase

type OffTimeDatabase interface {
	GetOffTimeRequest(ctx context.Context, ids ...string) ([]structs.OffTimeEntry, error)
	CreateOffTimeRequest(ctx context.Context, req *structs.OffTimeEntry) error
	DeleteOffTimeRequest(ctx context.Context, id ...string) error
	FindOffTimeRequests(ctx context.Context, from, to time.Time, approved *bool, userIds []string) ([]structs.OffTimeEntry, error)
	ApproveOffTimeRequest(ctx context.Context, id string, approval *structs.Approval) error
	AddOffTimeCost(ctx context.Context, cost *structs.OffTimeCosts) error
	GetOffTimeCosts(ctx context.Context, user_ids ...string) ([]structs.OffTimeCosts, error)
	DeleteOffTimeCosts(ctx context.Context, ids ...string) error
}

type WorkShiftDatabase

type WorkShiftDatabase interface {
	SaveWorkShift(context.Context, *structs.WorkShift) error
	DeleteWorkShift(context.Context, string) error
	ListWorkShifts(context.Context) ([]structs.WorkShift, error)
	GetShiftsForDay(ctx context.Context, weekDay time.Weekday, isHoliday bool) ([]structs.WorkShift, error)
}

type WorkTimeDatabase

type WorkTimeDatabase interface {
	SaveWorkTimePerWeek(ctx context.Context, wt *structs.WorkTime) error
	WorkTimeHistoryForStaff(ctx context.Context, staff string) ([]structs.WorkTime, error)
	GetCurrentWorkTimes(ctx context.Context, until time.Time) (map[string]structs.WorkTime, error)
	DeleteWorkTime(ctx context.Context, ids ...string) error
	GetWorktimeByID(ctx context.Context, id string) (*structs.WorkTime, error)
	UpdateWorkTime(ctx context.Context, wt *structs.WorkTime) error
}

Jump to

Keyboard shortcuts

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