bookings

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 14 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 {
	ListDayBookings(ctx context.Context, teacherID users.ID, date time.Time) ([]Booking, error)
	AddBookings(ctx context.Context, teacherID users.ID, studentID students.ID, startTime, endTime time.Time, count int) error
	MoveBooking(ctx context.Context, id ID, startTime, endTime time.Time) error
	SetBookingState(ctx context.Context, id ID, state State) error
}

type ID

type ID string

type Repo

type Repo struct {
	Pool *pgxpool.Pool
}

func (*Repo) AddBooking

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

func (*Repo) BookingStates

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

func (*Repo) CountBookingsByState

func (r *Repo) CountBookingsByState(ctx context.Context, teacherID users.ID) (map[string]map[State]int, error)

func (*Repo) GetLastBooking

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

func (*Repo) ListBookingsByState

func (r *Repo) ListBookingsByState(ctx context.Context, postponed State) ([]Booking, error)

func (*Repo) ListDayBookings

func (r *Repo) ListDayBookings(ctx context.Context, teacherID users.ID, date time.Time) ([]Booking, error)

func (*Repo) MoveBooking

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

func (*Repo) SetBookingState

func (r *Repo) SetBookingState(ctx context.Context, bookingID ID, 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) ReschedulePostponedBookings

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

type State

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

Jump to

Keyboard shortcuts

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