assignment

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInserted = errors.New("pgx CommandTag is not INSERT")
	ErrNotDeleted  = errors.New("pgx CommandTag is not DELETE")
)

errors

Functions

This section is empty.

Types

type Assignment

type Assignment struct {
	ID uuid.UUID `db:"uuid"`
	// Assignment day
	At time.Time `db:"at"`
	// From which chat assignment came from
	ChatID int64 `db:"chat_id"`
	// Assignee for duty
	Operator string `db:"operator"`
	// When assignment was created
	CreatedAt time.Time `db:"created_at"`
}

type AssignmentRepoData

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

func (*AssignmentRepoData) AddAssignment

func (asr *AssignmentRepoData) AddAssignment(ctx context.Context, as Assignment) error

func (AssignmentRepoData) Close

func (asr AssignmentRepoData) Close(ctx context.Context) error

func (*AssignmentRepoData) DeleteAssignment

func (asr *AssignmentRepoData) DeleteAssignment(ctx context.Context, uid uuid.UUID) error

func (AssignmentRepoData) GetAllChats

func (asr AssignmentRepoData) GetAllChats(ctx context.Context) ([]int64, error)

func (*AssignmentRepoData) GetAssignmentByDate

func (asr *AssignmentRepoData) GetAssignmentByDate(
	ctx context.Context,
	date time.Time,
	chatID int64,
) (Assignment, error)

func (*AssignmentRepoData) GetAssignmentSchedule

func (asr *AssignmentRepoData) GetAssignmentSchedule(
	ctx context.Context,
	due time.Time,
	chatID int64,
) ([]Assignment, error)

Return assignments due specified date and for specified chat

func (*AssignmentRepoData) GetAssignmentScheduleAllChats

func (asr *AssignmentRepoData) GetAssignmentScheduleAllChats(
	ctx context.Context,
	due time.Time,
) ([]Assignment, error)

Get assignments for all chats due specified date

func (*AssignmentRepoData) GetFreeSlots

func (asr *AssignmentRepoData) GetFreeSlots(
	ctx context.Context,
	due time.Time,
	chatID int64,
) ([]time.Time, error)

Return free duty slots for specified number of weeks

type AssignmentRepoer

type AssignmentRepoer interface {
	AddAssignment(ctx context.Context, as Assignment) error
	DeleteAssignment(ctx context.Context, id uuid.UUID) error
	GetAssignmentSchedule(ctx context.Context, due time.Time, chatID int64) ([]Assignment, error)
	GetAssignmentScheduleAllChats(ctx context.Context, due time.Time) ([]Assignment, error)
	GetAssignmentByDate(ctx context.Context, due time.Time, chatID int64) (Assignment, error)
	GetFreeSlots(ctx context.Context, due time.Time, chatID int64) ([]time.Time, error)
	GetAllChats(ctx context.Context) ([]int64, error)
	Close(ctx context.Context) error
}
var AssignmentRepo AssignmentRepoer

func InitAssignmentRepo

func InitAssignmentRepo(ctx context.Context, dsn string) (AssignmentRepoer, error)

Jump to

Keyboard shortcuts

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