bookings

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(svc BookingService, logger *slog.Logger) http.Handler

Types

type Booking

type Booking struct {
	StartTime time.Time        `json:"startTime"`
	EndTime   time.Time        `json:"endTime"`
	Student   students.Student `json:"student"`
	ID        ID               `json:"id"`
	State     State            `json:"state"`
	Teacher   users.User       `json:"teacher"`
}

type BookingService

type BookingService interface {
	List(context.Context, ListFilter) ([]Booking, error)
	AddBookings(ctx context.Context, teacherID users.ID, studentID students.ID, startTime, endTime time.Time, count int) error
	Reschedule(ctx context.Context, id ID, startTime, endTime time.Time) error
	SetState(ctx context.Context, id ID, state State) error
	MarkDayDone(ctx context.Context, teacherID users.ID, date time.Time) error
	ReschedulePostponedDayBookings(ctx context.Context, teacherID users.ID, date time.Time) error
}

type ID

type ID string

type ListFilter added in v0.3.0

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

func (ListFilter) ByBookingID added in v0.3.0

func (f ListFilter) ByBookingID(bookings ID) ListFilter

func (ListFilter) ByEndTime added in v0.3.0

func (f ListFilter) ByEndTime(t time.Time) ListFilter

func (ListFilter) ByStartTime added in v0.3.0

func (f ListFilter) ByStartTime(t time.Time) ListFilter

func (ListFilter) ByState added in v0.3.0

func (f ListFilter) ByState(state State) ListFilter

func (ListFilter) ByStudentID added in v0.3.0

func (f ListFilter) ByStudentID(id students.ID) ListFilter

func (ListFilter) ByTeacherID added in v0.3.0

func (f ListFilter) ByTeacherID(id users.ID) ListFilter

func (ListFilter) Where added in v0.3.0

func (f ListFilter) Where() (string, []any)

type Repo

type Repo struct {
	Pool *pgxpool.Pool
}

func (*Repo) Add added in v0.2.0

func (r *Repo) Add(ctx context.Context, booking Booking) error

func (*Repo) BookingStates

func (r *Repo) BookingStates() []State

func (*Repo) CountByState added in v0.2.0

func (r *Repo) CountByState(ctx context.Context, f ListFilter) (map[string]map[State]int, error)

func (*Repo) LastBooking added in v0.2.0

func (r *Repo) LastBooking(ctx context.Context, teacherID users.ID, studentID students.ID) (ID, time.Time, time.Time, error)

func (*Repo) List added in v0.2.0

func (r *Repo) List(ctx context.Context, f ListFilter) ([]Booking, error)

func (*Repo) Reschedule added in v0.3.0

func (r *Repo) Reschedule(ctx context.Context, bookingID ID, startTime time.Time, endTime time.Time) error

func (*Repo) SetState added in v0.2.0

func (r *Repo) SetState(ctx context.Context, bookingID ID, state State) error

func (*Repo) SetStateByFilter added in v0.3.0

func (r *Repo) SetStateByFilter(ctx context.Context, f ListFilter, state State) error

type Service

type Service struct {
	Repo
}

func (Service) AddBookings

func (s Service) AddBookings(ctx context.Context, teacherID users.ID, studentID students.ID, startTime, endTime time.Time, count int) error

func (Service) MarkDayDone added in v0.3.0

func (s Service) MarkDayDone(ctx context.Context, teacherID users.ID, date time.Time) error

func (Service) RescheduleBooking added in v0.3.0

func (s Service) RescheduleBooking(ctx context.Context, id ID, teacherID users.ID, studentID students.ID) error

func (Service) ReschedulePostponedBookings

func (s Service) ReschedulePostponedBookings(ctx context.Context) (int, error)

func (Service) ReschedulePostponedDayBookings added in v0.3.0

func (s Service) ReschedulePostponedDayBookings(ctx context.Context, teacherID users.ID, date time.Time) error

type State

type State string
const (
	Planned   State = "planned"
	Postponed State = "postponed"
	NoShow    State = "no-show"
	Done      State = "done"
)

Jump to

Keyboard shortcuts

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