Documentation ¶
Index ¶
- Variables
- func ComputeNormScores(recipes []*Recipe)
- func MulScore[T num.Number](s *Score, scalar T)
- func OpenDB() error
- type Categories
- func (i Categories) BitIndexString() string
- func (i Categories) Desc() string
- func (i Categories) HasFlag(f enums.BitFlag) bool
- func (i Categories) Int64() int64
- func (i Categories) IsValid() bool
- func (i Categories) MarshalText() ([]byte, error)
- func (i *Categories) Scan(value any) error
- func (i *Categories) SetFlag(on bool, f ...enums.BitFlag)
- func (i *Categories) SetInt64(in int64)
- func (i *Categories) SetString(s string) error
- func (i *Categories) SetStringOr(s string) error
- func (i Categories) String() string
- func (i *Categories) UnmarshalText(text []byte) error
- func (i Categories) Value() (driver.Value, error)
- func (i Categories) Values() []enums.Enum
- type Cuisines
- func (i Cuisines) BitIndexString() string
- func (i Cuisines) Desc() string
- func (i Cuisines) HasFlag(f enums.BitFlag) bool
- func (i Cuisines) Int64() int64
- func (i Cuisines) IsValid() bool
- func (i Cuisines) MarshalText() ([]byte, error)
- func (i *Cuisines) Scan(value any) error
- func (i *Cuisines) SetFlag(on bool, f ...enums.BitFlag)
- func (i *Cuisines) SetInt64(in int64)
- func (i *Cuisines) SetString(s string) error
- func (i *Cuisines) SetStringOr(s string) error
- func (i Cuisines) String() string
- func (i *Cuisines) UnmarshalText(text []byte) error
- func (i Cuisines) Value() (driver.Value, error)
- func (i Cuisines) Values() []enums.Enum
- type Entry
- type Group
- type Meal
- type Nutrition
- type Options
- type Recipe
- type Score
- type Sources
- func (i Sources) BitIndexString() string
- func (i Sources) Desc() string
- func (i Sources) HasFlag(f enums.BitFlag) bool
- func (i Sources) Int64() int64
- func (i Sources) IsValid() bool
- func (i Sources) MarshalText() ([]byte, error)
- func (i *Sources) Scan(value any) error
- func (i *Sources) SetFlag(on bool, f ...enums.BitFlag)
- func (i *Sources) SetInt64(in int64)
- func (i *Sources) SetString(s string) error
- func (i *Sources) SetStringOr(s string) error
- func (i Sources) String() string
- func (i *Sources) UnmarshalText(text []byte) error
- func (i Sources) Value() (driver.Value, error)
- func (i Sources) Values() []enums.Enum
- type User
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
DB is the gorm database for the app.
Functions ¶
func ComputeNormScores ¶
func ComputeNormScores(recipes []*Recipe)
ComputeNormScores computes the normalized base and text encoding scores for each recipe. The base and text encoding score indices already need to be computed. The normalized scores are the z-scores centered at 50 and bounded at roughly 0 and 100.
Types ¶
type Categories ¶
type Categories int64 //enums:bitflag
const ( Breakfast Categories = iota Brunch Lunch Dinner Dessert Snack Appetizer Side Drink Ingredient )
const CategoriesN Categories = 10
CategoriesN is the highest valid value for type Categories, plus one.
func CategoriesValues ¶
func CategoriesValues() []Categories
CategoriesValues returns all possible values for the type Categories.
func (Categories) BitIndexString ¶
func (i Categories) BitIndexString() string
BitIndexString returns the string representation of this Categories value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (Categories) Desc ¶
func (i Categories) Desc() string
Desc returns the description of the Categories value.
func (Categories) HasFlag ¶
func (i Categories) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (Categories) Int64 ¶
func (i Categories) Int64() int64
Int64 returns the Categories value as an int64.
func (Categories) IsValid ¶
func (i Categories) IsValid() bool
IsValid returns whether the value is a valid option for type Categories.
func (Categories) MarshalText ¶
func (i Categories) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*Categories) Scan ¶
func (i *Categories) Scan(value any) error
Value implements the [sql.Scanner] interface.
func (*Categories) SetFlag ¶
func (i *Categories) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*Categories) SetInt64 ¶
func (i *Categories) SetInt64(in int64)
SetInt64 sets the Categories value from an int64.
func (*Categories) SetString ¶
func (i *Categories) SetString(s string) error
SetString sets the Categories value from its string representation, and returns an error if the string is invalid.
func (*Categories) SetStringOr ¶
func (i *Categories) SetStringOr(s string) error
SetStringOr sets the Categories value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (Categories) String ¶
func (i Categories) String() string
String returns the string representation of this Categories value.
func (*Categories) UnmarshalText ¶
func (i *Categories) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (Categories) Value ¶
func (i Categories) Value() (driver.Value, error)
Scan implements the driver.Valuer interface.
func (Categories) Values ¶
func (i Categories) Values() []enums.Enum
Values returns all possible values for the type Categories.
type Cuisines ¶
type Cuisines int64 //enums:bitflag
const CuisinesN Cuisines = 17
CuisinesN is the highest valid value for type Cuisines, plus one.
func CuisinesValues ¶
func CuisinesValues() []Cuisines
CuisinesValues returns all possible values for the type Cuisines.
func (Cuisines) BitIndexString ¶
BitIndexString returns the string representation of this Cuisines value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (Cuisines) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Cuisines) SetFlag ¶
SetFlag sets the value of the given flags in these flags to the given value.
func (*Cuisines) SetString ¶
SetString sets the Cuisines value from its string representation, and returns an error if the string is invalid.
func (*Cuisines) SetStringOr ¶
SetStringOr sets the Cuisines value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (*Cuisines) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (Cuisines) Value ¶
Scan implements the driver.Valuer interface.
type Entry ¶
type Entry struct { gorm.Model `view:"-"` MealID uint `view:"-"` Meal Meal `view:"-"` UserID uint `view:"-"` User User `view:"-"` Time time.Time Category Categories Source Sources Taste int `view:"slider" min:"0" def:"50" max:"100"` Cost int `view:"slider" min:"0" def:"50" max:"100"` Effort int `view:"slider" min:"0" def:"50" max:"100"` Healthiness int `view:"slider" min:"0" def:"50" max:"100"` }
type Meal ¶
type Nutrition ¶
type Nutrition struct { Calories int // unit: Calories (kcal) Carbohydrate int // g Cholesterol int // mg Fiber int // g Protein int // g Fat int // g SaturatedFat int // g UnsaturatedFat int // g Sodium int // mg Sugar int // g }
Nutrition represents the nutritional information of a recipe
type Options ¶
type Options struct { Categories Categories Sources Sources Cuisines Cuisines TasteImportance int `view:"slider" min:"0" def:"50" max:"100"` RecencyImportance int `view:"slider" min:"0" def:"50" max:"100"` CostImportance int `view:"slider" min:"0" def:"50" max:"100"` EffortImportance int `view:"slider" min:"0" def:"50" max:"100"` HealthinessImportance int `view:"slider" min:"0" def:"50" max:"100"` }
func DefaultOptions ¶
func DefaultOptions() *Options
type Recipe ¶
type Recipe struct { Name string URL string Description string Image string Author string DatePublished time.Time DateModified time.Time Category []string `view:"-"` CategoryFlag Categories `json:"-" label:"Category"` Cuisine []string `view:"-"` CuisineFlag Cuisines `json:"-" label:"Cuisine"` Ingredients []string TotalTime string `view:"-"` PrepTime string `view:"-"` CookTime string `view:"-"` TotalTimeDuration time.Duration `json:"-" label:"Total time" viewif:"TotalTime!=\"\""` PrepTimeDuration time.Duration `json:"-" label:"Prep time" viewif:"PrepTime!=\"\""` CookTimeDuration time.Duration `json:"-" label:"Cook time" viewif:"CookTime!=\"\""` Yield int RatingValue float64 `view:"slider" min:"0" max:"5"` RatingCount int RatingScore int `view:"-" json:"-"` RatingWeight int `view:"-" json:"-"` Nutrition Nutrition Source string `json:"-"` // index score values for base information about a recipe (using info like calories, time, ingredients, etc) BaseScoreIndex Score `json:"-"` // percentile values of BaseScoreIndex BaseScore Score // keyed by meal ID TextEncodingScores map[uint]float32 `json:"-"` // index score values for text encoding based scores EncodingScoreIndex Score `json:"-"` // percentile values of EncodingScoreIndex EncodingScore Score `json:"-"` Score Score `json:"-"` }
A Recipe is an external recipe that can be used for new meal recommendations
func (*Recipe) ComputeBaseScoreIndex ¶
func (r *Recipe) ComputeBaseScoreIndex()
ComputeBaseScoreIndex computes and sets the base score index for the given recipe
type Sources ¶
type Sources int64 //enums:bitflag
const SourcesN Sources = 4
SourcesN is the highest valid value for type Sources, plus one.
func SourcesValues ¶
func SourcesValues() []Sources
SourcesValues returns all possible values for the type Sources.
func (Sources) BitIndexString ¶
BitIndexString returns the string representation of this Sources value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (Sources) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Sources) SetFlag ¶
SetFlag sets the value of the given flags in these flags to the given value.
func (*Sources) SetString ¶
SetString sets the Sources value from its string representation, and returns an error if the string is invalid.
func (*Sources) SetStringOr ¶
SetStringOr sets the Sources value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (*Sources) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (Sources) Value ¶
Scan implements the driver.Valuer interface.