core

package
v0.0.0-...-95a30eb Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BConversionUtil

type BConversionUtil interface {
	ConvertScheduleToAppointmentSchedule(schedule *models.Schedule, availability []string) *models.AppointmentSchedule
	ConvertTimeSlotsStringToAppointments(timeSlots string, date *time.Time) *[]models.Appointment
	CalculateDate(timePointerIndex int, baseDate *time.Time, end bool) *time.Time
}

func NewBConversionUtil

func NewBConversionUtil(bTimeConfig *BTimeConfig) (BConversionUtil, error)

Instantiates a new BinaryConversionUtil, which is responsible for handling the conversion of schedules to Appointments

type BConversionUtilImpl

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

func (*BConversionUtilImpl) CalculateDate

func (bcu *BConversionUtilImpl) CalculateDate(timePointerIndex int, baseDate *time.Time, end bool) *time.Time

Takes a time pointer, base date — the date on which it occured, and boolean if it is the end of an appointmen and converts it into a Date

func (*BConversionUtilImpl) ConvertScheduleToAppointmentSchedule

func (bcu *BConversionUtilImpl) ConvertScheduleToAppointmentSchedule(schedule *models.Schedule, availability []string) *models.AppointmentSchedule

Takes a schedule and the schedule's remaining availability, and converts each of the bTime representations into Appointment arrays

func (*BConversionUtilImpl) ConvertTimeSlotsStringToAppointments

func (bcu *BConversionUtilImpl) ConvertTimeSlotsStringToAppointments(timeSlots string, date *time.Time) *[]models.Appointment

Takes a set of timeslots and the date on which they occurred and converts them into Appointments

type BPointerCalculator

type BPointerCalculator interface {
	FindBPointerIncludingDay(date *time.Time) int
	FindBPointerModiferForDayOfWeek(date *time.Time) int
	FindBPointer(date *time.Time) int
	FindWeekDay(date *time.Time) int
}

func NewBPointerCalculator

func NewBPointerCalculator(bTimeConfig *BTimeConfig) (BPointerCalculator, error)

Instantiates a new BPointerCalculatorImpl, which is responsible for calculating bPointers, for use by other bTime classes

type BPointerCalculatorImpl

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

func (*BPointerCalculatorImpl) FindBPointer

func (bpc *BPointerCalculatorImpl) FindBPointer(date *time.Time) int

Finds a the pointer for a given date in time based on the instatiated time interval within a given day

func (*BPointerCalculatorImpl) FindBPointerIncludingDay

func (bpc *BPointerCalculatorImpl) FindBPointerIncludingDay(date *time.Time) int

Finds a the pointer for a given date in time based on the instatiated time interval, including day of the week

func (*BPointerCalculatorImpl) FindBPointerModiferForDayOfWeek

func (bpc *BPointerCalculatorImpl) FindBPointerModiferForDayOfWeek(date *time.Time) int

Finds the pointer modifer to correct for day of the week

func (*BPointerCalculatorImpl) FindWeekDay

func (bpc *BPointerCalculatorImpl) FindWeekDay(date *time.Time) int

Finds the numeric day of the week with 0 = Sunday

type BScheduleUtil

type BScheduleUtil interface {
	MergeScheduleBStringsWithTest(timeSlot *models.Appointment, schedule string) (*string, error)
	MergeScheduleBStringsWithTestBase(apptBString string, schedule string) (*string, error)
	MergeScheduleBStringWithTest(timeSlotBString string, schedule string) (*string, error)
	ModifyScheduleAndBooking(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)
	ModifyScheduleAndBookingInterval(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)
	TestViabilityAndCompute(binary1 int64, binary2 int64) (*int64, error)
	DeleteAppointment(timeSlotToDelete *models.Appointment, scheduleSlot string) (*string, error)
	DeleteAppointmentBString(bStringToDelete string, scheduleSlot string) (*string, error)
	DeleteAppointmentInterval(timeSlotBString string, scheduleInterval string) (*string, error)
	ValidDeletion(baseNumber int64, toDeleteNumber int64) bool
}

func NewBScheduleUtil

func NewBScheduleUtil(bTimeConfig *BTimeConfig) (BScheduleUtil, error)

Instantiates a new BScheduleUtil, which is responsible for handling scheduling using bit manipulations

type BScheduleUtilImpl

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

func (*BScheduleUtilImpl) DeleteAppointment

func (bschu *BScheduleUtilImpl) DeleteAppointment(timeSlotToDelete *models.Appointment, scheduleSlot string) (*string, error)

Tests removal a give time slot from a given time interval and if valid removes it

NB: This is also used for calculating remaining availability

func (*BScheduleUtilImpl) DeleteAppointmentBString

func (bschu *BScheduleUtilImpl) DeleteAppointmentBString(bStringToDelete string, scheduleSlot string) (*string, error)

Tests removal a given time slot from a given time interval and if valid removes it

NB: This is also used for calculating remaining availability

func (*BScheduleUtilImpl) DeleteAppointmentInterval

func (bschu *BScheduleUtilImpl) DeleteAppointmentInterval(timeSlotBString string, scheduleInterval string) (*string, error)

Tests removal a given time slot from a given time interval and if valid removes it

NB: Deleted appts can restore availability not add new availability as appts can only be created where the is availability and availability cannot be deleted when there is a concurrent appt

func (*BScheduleUtilImpl) MergeScheduleBStringWithTest

func (bschu *BScheduleUtilImpl) MergeScheduleBStringWithTest(timeSlotBString string, schedule string) (*string, error)

Tests that an timeSlot does not overlap with another timeSlot, if it does not overlap, the timeSlot is added to the bookings, else throws an error

func (*BScheduleUtilImpl) MergeScheduleBStringsWithTest

func (bschu *BScheduleUtilImpl) MergeScheduleBStringsWithTest(timeSlot *models.Appointment, schedule string) (*string, error)

Tests that an appointment does not overlap with another appointment, if it does not overlap, the appointment is added to the bookings, else throws an error

func (*BScheduleUtilImpl) MergeScheduleBStringsWithTestBase

func (bschu *BScheduleUtilImpl) MergeScheduleBStringsWithTestBase(apptBString string, schedule string) (*string, error)

Tests that an appointment does not overlap with another appointment, if it does not overlap, the appointment is added to the bookings, else throws an error

func (*BScheduleUtilImpl) ModifyScheduleAndBooking

func (bschu *BScheduleUtilImpl) ModifyScheduleAndBooking(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)

Tests that an timeSlot does not overlap with another timeSlot, if it does not overlap, the timeSlot is added to the bookings, else throw an error. Additionally, this method checks that the timeslot is within availabilities (test)

NB: If testing a booking update, test that booking fits in avail. This means that bookingsUpdate the inputs are (bookings, bookings, appt)

func (*BScheduleUtilImpl) ModifyScheduleAndBookingInterval

func (bschu *BScheduleUtilImpl) ModifyScheduleAndBookingInterval(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)

Tests that an timeSlot does not overlap with another timeSlot, if it does not overlap, the timeSlot is added to the bookings, else throws an error. Additionally, this method checks that the timeslot is within availabilities (test). This occurs within a schedule interval

NB: If testing a booking update, test that booking fits in avail. This means that bookingsUpdate the inputs are (bookings, bookings, appt)

func (*BScheduleUtilImpl) TestViabilityAndCompute

func (bschu *BScheduleUtilImpl) TestViabilityAndCompute(binary1 int64, binary2 int64) (*int64, error)

Tests that two time intervals do not overlap

func (*BScheduleUtilImpl) ValidDeletion

func (bschu *BScheduleUtilImpl) ValidDeletion(baseNumber int64, toDeleteNumber int64) bool

Tests removal a give time slot from a given time interval

type BScheduler

type BScheduler interface {
	UpdateScheduleWithAppointmentSchedule(proposedAppointmentSchedule *models.AppointmentSchedule, schedule *models.Schedule) (*models.AppointmentSchedule, error)
	ConvertScheduleToAppointmentSchedule(schedule *models.Schedule) (*models.AppointmentSchedule, error)
	GetCurrentAvailability(schedule *models.Schedule) (*[]string, error)
	UpdateSchedule(proposedSchedule *models.Schedule, schedule *models.Schedule) (*models.Schedule, error)
	ProcessAppointments(appointments *[]models.Appointment, schedule *models.Schedule, actionType constants.ScheduleAction) (*models.Schedule, error)
	ProcessAppointment(appointment *models.Appointment, schedule *models.Schedule, actionType constants.ScheduleAction) (*models.Schedule, error)
	ComposeAppointments(appointment *models.Appointment) *models.AppointmentDuo
	HandleBookingUpdate(appointment *models.Appointment, schedule *models.Schedule, firstAppt *models.Appointment) (*models.Schedule, error)
	HandleBookingUpdateBString(appointmentsBStrings []string, schedule *models.Schedule) (*models.Schedule, error)
	DeleteAppointment(appointment *models.Appointment, schedule *models.Schedule, firstAppt *models.Appointment) (*models.Schedule, error)
	DeleteAppointments(appointmentsBStrings []string, schedule *models.Schedule) (*models.Schedule, error)
}

func NewBScheduler

func NewBScheduler(timeInterval int) (BScheduler, error)

Instantiates a new BScheduler, is responsible or maintaining of scheduling using binary Scheduler

NB: A time interval of 5 is usually adequate for most implementations

NB: The time interval must be a factor of 60,

ie. 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, or 60

type BSchedulerImpl

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

func (*BSchedulerImpl) ComposeAppointments

func (bs *BSchedulerImpl) ComposeAppointments(appointment *models.Appointment) *models.AppointmentDuo

Utility function to split appointments that cross the day boundary

func (*BSchedulerImpl) ConvertScheduleToAppointmentSchedule

func (bs *BSchedulerImpl) ConvertScheduleToAppointmentSchedule(schedule *models.Schedule) (*models.AppointmentSchedule, error)

Takes a schedule and converts into an array of appointments for each date

NB: This is a passthrough to the configured BTimeFactory

func (*BSchedulerImpl) DeleteAppointment

func (bs *BSchedulerImpl) DeleteAppointment(appointment *models.Appointment, schedule *models.Schedule, firstAppt *models.Appointment) (*models.Schedule, error)

Takes an appointment and tests if the appointment to delete is valid, if not throws an error, if it is the schedule is updated to reflect the deletion

func (*BSchedulerImpl) DeleteAppointments

func (bs *BSchedulerImpl) DeleteAppointments(appointmentsBStrings []string, schedule *models.Schedule) (*models.Schedule, error)

Takes an array of appointments and tests if the appointments to delete are valid, if not throws an error, if they are the schedule is updated to reflect the deletion

func (*BSchedulerImpl) GetCurrentAvailability

func (bs *BSchedulerImpl) GetCurrentAvailability(schedule *models.Schedule) (*[]string, error)

Takes a valid schedule and computes the remaining availability based on the total availability and current bookings, throws an error if an invalid scehdule is passed

func (*BSchedulerImpl) HandleBookingUpdate

func (bs *BSchedulerImpl) HandleBookingUpdate(appointment *models.Appointment, schedule *models.Schedule, firstAppt *models.Appointment) (*models.Schedule, error)

Takes an appointment and tests if the appointment update is valid, if not it throws an error, if it is the schedule is updated

func (*BSchedulerImpl) HandleBookingUpdateBString

func (bs *BSchedulerImpl) HandleBookingUpdateBString(appointmentsBStrings []string, schedule *models.Schedule) (*models.Schedule, error)

Takes an array of appointments and tests if the appointment update are valid, if not it throws an error, if they are the schedule is updated

func (*BSchedulerImpl) ProcessAppointment

func (bs *BSchedulerImpl) ProcessAppointment(appointment *models.Appointment, schedule *models.Schedule, actionType constants.ScheduleAction) (*models.Schedule, error)

Takes an appointment and update type and tests if the appointment update is valid, if not it throws an error, if it is the schedule is updated

func (*BSchedulerImpl) ProcessAppointments

func (bs *BSchedulerImpl) ProcessAppointments(appointments *[]models.Appointment, schedule *models.Schedule, actionType constants.ScheduleAction) (*models.Schedule, error)

Takes an slice of appointments and update type and tests if the appointment updates are valid, if not it throws an error, if they are the schedule is updated

func (*BSchedulerImpl) UpdateSchedule

func (bs *BSchedulerImpl) UpdateSchedule(proposedSchedule *models.Schedule, schedule *models.Schedule) (*models.Schedule, error)

Tests a propsoed schedule update and updates the schedule, if the update is valid or throws an error if the update is not valid

func (*BSchedulerImpl) UpdateScheduleWithAppointmentSchedule

func (bs *BSchedulerImpl) UpdateScheduleWithAppointmentSchedule(proposedAppointmentSchedule *models.AppointmentSchedule, schedule *models.Schedule) (*models.AppointmentSchedule, error)

Tests a proposed appointment schedule update and updates the schedule, if the update is valid or throws an error if the update is not valid

type BStringUtil

type BStringUtil interface {
	GenerateBString(appt *models.Appointment) (*string, error)
	GenerateBStringFromAppointments(appointments *[]models.Appointment) (*[]string, error)
	TimeStringSplit(scheduleString string) []string
	ParseBString(bString string) (*int64, error)
	DecimalToBString(decimal float64) string
}

func NewBStringUtil

func NewBStringUtil(bTimeConfig *BTimeConfig) (BStringUtil, error)

Instantiates a new BStringUtil, which is responsible for generating and formatting the bStrings used by this package

NB: Typically a temporal resolution of 5 mins is sufficient, as it constitutes the smallest billable unit in most juristictions

type BStringUtilImpl

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

func (*BStringUtilImpl) DecimalToBString

func (bsu *BStringUtilImpl) DecimalToBString(decimal float64) string

Converts number into a bString representation with the given scheduling interval

func (*BStringUtilImpl) GenerateBString

func (bsu *BStringUtilImpl) GenerateBString(appt *models.Appointment) (*string, error)

Generates a bString representation of a given appointment, assuming it is valid. If the appointment is invalid, it will throw an error

func (*BStringUtilImpl) GenerateBStringFromAppointments

func (bsu *BStringUtilImpl) GenerateBStringFromAppointments(appointments *[]models.Appointment) (*[]string, error)

Generates a bString representation of a given array of appointments, assuming it is valid. If the appointment is invalid, it will throw an error

NB: This method generates a representation of the entire week

NB: Assumes appointments in array don't overlap

func (*BStringUtilImpl) ParseBString

func (bsu *BStringUtilImpl) ParseBString(bString string) (*int64, error)

Converts bString representation of a number into a number for calculation purposes

func (*BStringUtilImpl) TimeStringSplit

func (bsu *BStringUtilImpl) TimeStringSplit(scheduleString string) []string

Splits each schedule BString into a string of length defined in the regex

type BTimeConfig

type BTimeConfig struct {
	TimeInterval            int
	IntervalsInHour         int
	IntervalsInDay          int
	IntervalsInWeek         int
	BStringSplitRegexStr    *regexp.Regexp
	BStringDaySplitRegexStr *regexp.Regexp
	EmptyHour               string
	EmptyDay                string
}

func BuildConfigFromTimeInterval

func BuildConfigFromTimeInterval(timeInterval int) (*BTimeConfig, error)

type BTimeFactory

type BTimeFactory interface {
	ParseBString(bString string) (*int64, error)
	GenerateBString(appt *models.Appointment) (*string, error)
	GenerateBStringFromAppointments(appointments *[]models.Appointment) (*[]string, error)
	TimeStringSplit(scheduleString string) []string
	DecimalToBString(decimal float64) string
	TestViabilityAndCompute(binary1 int64, binary2 int64) (*int64, error)
	DeleteAppointment(timeSlotToDelete *models.Appointment, scheduleSlot string) (*string, error)
	DeleteAppointmentBString(timeSlotToDelete string, scheduleSlot string) (*string, error)
	ModifyScheduleAndBooking(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)
	ConvertScheduleToAppointmentSchedule(schedule *models.Schedule, availability []string) *models.AppointmentSchedule
	FindWeekDay(date *time.Time) int
}

func NewBTimeFactory

func NewBTimeFactory(timeInterval int) (BTimeFactory, error)

Instantiates a new BTimeFactory, which manages and exposes various binary scheduling and string utils

NB: Typically a temporal resolution of 5 mins is sufficient, as it constitutes the smallest billable unit in most juristictions

NB: The time interval must be a factor of 60,

ie. 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, or 60

type BTimeFactoryImpl

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

func (*BTimeFactoryImpl) ConvertScheduleToAppointmentSchedule

func (btf *BTimeFactoryImpl) ConvertScheduleToAppointmentSchedule(schedule *models.Schedule, availability []string) *models.AppointmentSchedule

Takes a schedule and availabilty converting them into an array of appointments for each date

NB: This is a passthrough to the configured BConversionUtil

func (*BTimeFactoryImpl) DecimalToBString

func (btf *BTimeFactoryImpl) DecimalToBString(decimal float64) string

Converts number into a bString representation with the given scheduling interval

NB: This is a passthrough to the configured bStringUtil

func (*BTimeFactoryImpl) DeleteAppointment

func (btf *BTimeFactoryImpl) DeleteAppointment(timeSlotToDelete *models.Appointment, scheduleSlot string) (*string, error)

Tests removal a give time slot from a given time interval and if valid removes it, else throws an error

NB: This is also used for calculating remaining availability

NB: This is a passthrough to the configured bScheduleUtil

func (*BTimeFactoryImpl) DeleteAppointmentBString

func (btf *BTimeFactoryImpl) DeleteAppointmentBString(timeSlotToDelete string, scheduleSlot string) (*string, error)

Tests removal a give time slot from a given time interval and if valid removes it, else throws an error

NB: This is also used for calculating remaining availability

NB: This is a passthrough to the configured bScheduleUtil

func (*BTimeFactoryImpl) FindWeekDay

func (btf *BTimeFactoryImpl) FindWeekDay(date *time.Time) int

Finds the numeric day of the week with 0 = Sunday

func (*BTimeFactoryImpl) GenerateBString

func (btf *BTimeFactoryImpl) GenerateBString(appt *models.Appointment) (*string, error)

Generates a bString representation of a given appointment, assuming it is valid. If the appointment is invalid, it throws an error

NB: This is a passthrough to the configured bStringUtil

func (*BTimeFactoryImpl) GenerateBStringFromAppointments

func (btf *BTimeFactoryImpl) GenerateBStringFromAppointments(appointments *[]models.Appointment) (*[]string, error)

Generates a bString representation of a given array of appointments, assuming it is valid. If the appointment is invalid, it will throw an error

NB: This method generates a representation of the entire week

NB: Assumes appointments in array don't overlap

NB: This is a passthrough to the configured bStringUtil

func (*BTimeFactoryImpl) ModifyScheduleAndBooking

func (btf *BTimeFactoryImpl) ModifyScheduleAndBooking(scheduleBStringToModify string, scheduleBStringToTest string, appt string) (*string, error)

Tests that an timeSlot does not overlap with another timeSlot, if it does not overlap, the timeSlot is added to the bookings, else throw an error. Additionally, this method checks that the timeslot is within availabilities (test)

NB: If testing a booking update, test that booking fits in avail This means that bookingsUpdate the inputs are (bookings, bookings, appt)

NB: This is a passthrough to the configured bScheduleUtil

func (*BTimeFactoryImpl) ParseBString

func (btf *BTimeFactoryImpl) ParseBString(bString string) (*int64, error)

Converts bString representation of a number into a number for calculation purposes

NB: This is a passthrough to the configured bStringUtil

func (*BTimeFactoryImpl) TestViabilityAndCompute

func (btf *BTimeFactoryImpl) TestViabilityAndCompute(binary1 int64, binary2 int64) (*int64, error)

Tests that two time intervals do not overlap, throwing an error if they do

NB: This is a passthrough to the configured bScheduleUtil

func (*BTimeFactoryImpl) TimeStringSplit

func (btf *BTimeFactoryImpl) TimeStringSplit(scheduleString string) []string

Splits each schedule bString into a string of length defined in the regex

NB: This is a passthrough to the configured bStringUtil

Jump to

Keyboard shortcuts

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