reservation

package
v0.0.0-...-e6b7f3d Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LimitIncoming = 5

Variables

View Source
var (
	ErrInvalidReservation = errors.New("invalid reservation")
	ErrUserNotConfirmed   = errors.New("you must confirm your email to create a reservation")
	ErrUnauthorized       = errors.New("unauthorized access")
	ErrLimitReservations  = fmt.Errorf("you can't create more than %d incoming reservations", LimitIncoming)
	ErrInvalidFeatureDate = errors.New("invalid feature date")
)
View Source
var Table = "reservations"

Functions

func Create

func Create(ctx context.Context, dbConn *gorm.DB, newReservation *NewReservation) error

Create operates as controller to create a new reservation

Types

type BookedReservation

type BookedReservation struct {
	ID      int       `json:"id"`
	SlotID  int       `json:"slot_id"`
	CourtID int       `json:"court_id"`
	Date    time.Time `json:"date"`
}

BookedReservation contains the schema for booked reservations

func ReadBooked

func ReadBooked(ctx context.Context, dbConn *gorm.DB) ([]*BookedReservation, error)

ReadBooked operates as controller to find all booked slots for the next 30 days

type NewReservation

type NewReservation struct {
	UserID    int       `json:"-"`
	SlotID    int       `json:"slot_id"`
	CourtID   int       `json:"court_id"`
	Date      time.Time `json:"date"`
	CreatedAt time.Time `json:"-"`
}

NewReservation contains the schema to create new identity

type Reservation

type Reservation struct {
	ID        int       `json:"id" gorm:"primary_key;unique;not null"`
	UserID    int       `json:"user_id" gorm:"not null"`
	SlotID    int       `json:"slot_id" gorm:"not null"`
	CourtID   int       `json:"court_id" gorm:"not null"`
	Date      time.Time `json:"date" gorm:"not null"`
	CreatedAt time.Time `json:"created_at" gorm:"default:CURRENT_TIMESTAMP;not null"`
}

Reservation contains the schema for specific identity

func Read

func Read(ctx context.Context, dbConn *gorm.DB) ([]*Reservation, error)

Read operates as controller to list reservations

func ReadCourtID

func ReadCourtID(ctx context.Context, dbConn *gorm.DB, courtID string) ([]*Reservation, error)

ReadCourtID operates as controller to list reservations by court ID

func ReadUserID

func ReadUserID(ctx context.Context, dbConn *gorm.DB, userID string) ([]*Reservation, error)

ReadUserID operates as controller to list reservations by user ID

type Statistics

type Statistics struct {
	Total      int            `json:"total"`
	LastWeek   int            `json:"last_week"`
	LastMonth  int            `json:"last_month"`
	Incoming   int            `json:"incoming"`
	PerCourt   map[string]int `json:"per_court"`
	PerSlot    map[string]int `json:"per_slot"`
	PerWeekday map[string]int `json:"per_weekday"`
}

Metrics contains the schema for reservations metrics

func ReadStatistics

func ReadStatistics(ctx context.Context, dbConn *gorm.DB) (*Statistics, error)

ReadStatistics operates as controller to calculate statistics for reservations

Jump to

Keyboard shortcuts

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