models

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	StatusDraft            = "draft"
	StatusProcessing       = "processing"
	StatusProcessingFailed = "processing_failed"
	StatusReview           = "review"
	StatusPublished        = "published"
	StatusRejected         = "rejected"
)

Status values mirror the Rails workflow.

View Source
const (
	TagContextCookingMethods      = "cooking_methods"
	TagContextCulturalInfluences  = "cultural_influences"
	TagContextCourses             = "courses"
	TagContextDietaryRestrictions = "dietary_restrictions"
)

TagContext values mirror Rails acts_as_taggable_on contexts.

Variables

AllTagContexts in display order.

Functions

func RatingGlyphsFor

func RatingGlyphsFor(v int) string

RatingGlyphsFor returns a "★★★★☆" string for a 1–5 value.

Types

type AIClassifierRun

type AIClassifierRun struct {
	ID           int64      `db:"id"`
	RecipeID     *int64     `db:"recipe_id"`
	ServiceClass string     `db:"service_class"`
	Adapter      string     `db:"adapter"`
	AIModel      string     `db:"ai_model"`
	SystemPrompt string     `db:"system_prompt"`
	UserPrompt   string     `db:"user_prompt"`
	RawResponse  string     `db:"raw_response"`
	Success      bool       `db:"success"`
	ErrorClass   string     `db:"error_class"`
	ErrorMessage string     `db:"error_message"`
	StartedAt    *time.Time `db:"started_at"`
	CompletedAt  *time.Time `db:"completed_at"`
	CreatedAt    time.Time  `db:"created_at"`
}

AIClassifierRun is an audit record for every AI pipeline call, mirroring the Rails ai_classifier_runs table.

func (*AIClassifierRun) DurationMS

func (r *AIClassifierRun) DurationMS() int64

DurationMS returns the duration in milliseconds, or -1 if not complete.

type Recipe

type Recipe struct {
	ID              int64     `db:"id" json:"id"`
	Name            string    `db:"name" json:"name"`
	Description     string    `db:"description" json:"description"`
	Directions      string    `db:"directions" json:"directions"`
	PreparationTime *int      `db:"preparation_time" json:"preparation_time"`
	CookingTime     *int      `db:"cooking_time" json:"cooking_time"`
	Servings        *int      `db:"servings" json:"servings"`
	ServingUnits    string    `db:"serving_units" json:"serving_units"`
	SourceURL       string    `db:"source_url" json:"source_url"`
	SourceText      string    `db:"source_text" json:"source_text"`
	Status          string    `db:"status" json:"status"`
	CreatedAt       time.Time `db:"created_at" json:"created_at"`
	UpdatedAt       time.Time `db:"updated_at" json:"updated_at"`

	IsBread bool `db:"is_bread" json:"is_bread"`

	Rating *int   `db:"rating" json:"rating"` // 1–5, nullable
	Notes  string `db:"notes" json:"notes"`

	// Populated on load when needed.
	Ingredients []RecipeIngredient `db:"-" json:"ingredients"`
	Tags        []Tag              `db:"-" json:"tags"`
}

Recipe is the core domain model.

func (*Recipe) IsFailed

func (r *Recipe) IsFailed() bool

IsFailed returns true when AI extraction failed.

func (*Recipe) IsProcessing

func (r *Recipe) IsProcessing() bool

IsProcessing returns true when AI extraction is in flight.

func (*Recipe) IsPublished

func (r *Recipe) IsPublished() bool

IsPublished returns true when the recipe is public.

func (*Recipe) RatingGlyphs

func (r *Recipe) RatingGlyphs() string

RatingGlyphs returns a "★★★★☆" string for the rating, or "" if unrated.

func (*Recipe) TagsByContext

func (r *Recipe) TagsByContext(ctx string) []string

TagsByContext returns all tags matching the given context.

func (*Recipe) TimingSummary

func (r *Recipe) TimingSummary() string

TimingSummary returns a human-readable timing string.

type RecipeIngredient

type RecipeIngredient struct {
	ID              int64    `db:"id" json:"id"`
	RecipeID        int64    `db:"recipe_id" json:"recipe_id"`
	IngredientID    int64    `db:"ingredient_id" json:"ingredient_id"`
	Quantity        string   `db:"quantity" json:"quantity"`
	QuantityNumeric *float64 `db:"quantity_numeric" json:"quantity_numeric"`
	Unit            string   `db:"unit" json:"unit"`
	UnitWeightG     *float64 `db:"unit_weight_g" json:"unit_weight_g"`
	Descriptor      string   `db:"descriptor" json:"descriptor"`
	Section         string   `db:"section" json:"section"`
	Position        int      `db:"position" json:"position"`

	// Populated via JOIN when loading recipe ingredients.
	IngredientName string `db:"ingredient_name" json:"ingredient_name"`
	IngredientType string `db:"ingredient_type" json:"ingredient_type"`
}

RecipeIngredient is the join model between Recipe and Ingredient, carrying quantity, unit, descriptor, and section metadata.

func (*RecipeIngredient) DisplayString

func (ri *RecipeIngredient) DisplayString() string

DisplayString returns a human-readable ingredient line. e.g. "1 cup flour, sifted" or "2 large eggs"

type Tag

type Tag struct {
	ID      int64  `db:"id" json:"id"`
	Name    string `db:"name" json:"name"`
	Context string `db:"context" json:"context"`
}

Tag represents a classification label in a specific context.

Jump to

Keyboard shortcuts

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