model

package
v0.0.0-...-f3d3b89 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlreadyRegisteredRegex = regexp.MustCompile(regexp.QuoteMeta("Ya inscrito"))
View Source
var HHMMTimeRegex = regexp.MustCompile("[0-9]{2}:[0-9]{2}")
View Source
var NumberRegex = regexp.MustCompile("[0-9]+")

Functions

func FindTable

func FindTable(res *http.Response) (selection *goquery.Selection, err error)

Find the target table from an HTTP response

func FirstAvailableAtLeast1HourAwayCondition

func FirstAvailableAtLeast1HourAwayCondition(slot ReservationSlot, slotTime timerange.TimeRange, day time.Weekday, t timerange.TimeRange) bool

func FirstAvailableCondition

func FirstAvailableCondition(slot ReservationSlot, slotTime timerange.TimeRange, day time.Weekday, t timerange.TimeRange) bool

Types

type Reservation

type Reservation struct {
	Slot ReservationSlot
	At   timerange.TimeRange
}

type ReservationSlot

type ReservationSlot struct {
	Name         string
	Availability int64
	Reserved     bool
	URL          *url.URL
}

type ReservationsWeek

type ReservationsWeek struct {
	SlotTimes []timerange.TimeRange
	Slots     map[time.Weekday][]ReservationSlot
}

func MarshalTable

func MarshalTable(data *TableData) (reservations *ReservationsWeek, err error)

func NewReservarionsWeek

func NewReservarionsWeek() *ReservationsWeek

func (*ReservationsWeek) FindSlot

func (*ReservationsWeek) FindSlotFirst

func (r *ReservationsWeek) FindSlotFirst(day time.Weekday, t timerange.TimeRange) *ReservationSlot

func (*ReservationsWeek) FindSlotFirstAvailable

func (r *ReservationsWeek) FindSlotFirstAvailable(day time.Weekday, t timerange.TimeRange) *ReservationSlot

func (*ReservationsWeek) FindSlotFirstAvailableAtLeast1HourAway

func (r *ReservationsWeek) FindSlotFirstAvailableAtLeast1HourAway(day time.Weekday, t timerange.TimeRange) *ReservationSlot

func (*ReservationsWeek) FindSlotWithStrategy

func (r *ReservationsWeek) FindSlotWithStrategy(day time.Weekday, t timerange.TimeRange, strat SlotSearchStrategy) *ReservationSlot

func (*ReservationsWeek) GetReservations

func (r *ReservationsWeek) GetReservations() (reservations map[time.Weekday]Reservation)

func (*ReservationsWeek) SlotAt

type SlotSearchStrategy

type SlotSearchStrategy int
const (
	First SlotSearchStrategy = iota
	FirstAvailable
	FirstAvailableAtLeast1HourAway
)

type TableData

type TableData struct {
	ColumnHeaders []string       `pagser:"thead tr th->eachText()"`
	Rows          []TableDataRow `pagser:"tbody tr"`
}

func ParseHTMLTable

func ParseHTMLTable(s *goquery.Selection) (data TableData, err error)

type TableDataRow

type TableDataRow struct {
	Columns []struct {
		RawText string `pagser:"->html()"`
		URL     string `pagser:"a->attr(href)"`
	} `pagser:"td"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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