Documentation
¶
Index ¶
- func PgvectorLiteral(v []float32) string
- type AllergenRepository
- func (r *AllergenRepository) CreateAnalysis(analysis *models.AllergenAnalysis) error
- func (r *AllergenRepository) DeleteAnalysisByRecipeID(recipeID uint) error
- func (r *AllergenRepository) GetAnalysisByNodeID(nodeID uint) (*models.AllergenAnalysis, error)
- func (r *AllergenRepository) GetAnalysisByRecipeID(recipeID uint) (*models.AllergenAnalysis, error)
- func (r *AllergenRepository) UpdateAnalysis(analysis *models.AllergenAnalysis) error
- type CanonicalRecipeRepo
- type CanonicalRecipeRepository
- func (r *CanonicalRecipeRepository) GetByID(id uint) (*models.CanonicalRecipe, error)
- func (r *CanonicalRecipeRepository) GetByNormalizedURL(normalizedURL string) (*models.CanonicalRecipe, error)
- func (r *CanonicalRecipeRepository) GetStaleEntries(maxAge time.Duration) ([]models.CanonicalRecipe, error)
- func (r *CanonicalRecipeRepository) IncrementHitCount(id uint) error
- func (r *CanonicalRecipeRepository) Upsert(entry *models.CanonicalRecipe) error
- type FamilyRepository
- func (r *FamilyRepository) CreateFamily(family *models.Family) error
- func (r *FamilyRepository) CreateFamilyMember(member *models.FamilyMember) error
- func (r *FamilyRepository) DeleteFamilyMember(id uint) error
- func (r *FamilyRepository) GetFamilyByOwnerID(ownerID uint) (*models.Family, error)
- func (r *FamilyRepository) GetFamilyMemberByID(id uint) (*models.FamilyMember, error)
- func (r *FamilyRepository) GetOrCreateDietaryProfile(memberID uint) (*models.DietaryProfile, error)
- func (r *FamilyRepository) UpdateDietaryProfile(profile *models.DietaryProfile) error
- func (r *FamilyRepository) UpdateFamilyMember(member *models.FamilyMember) error
- type NotFoundError
- type RecipeRepo
- type RecipeRepository
- func (r *RecipeRepository) AddNodeToTree(node *models.RecipeNode, setActive bool) error
- func (r *RecipeRepository) CreateRecipe(recipe *models.Recipe) error
- func (r *RecipeRepository) CreateRecipeTree(recipeID uint, rootNode *models.RecipeNode) (*models.RecipeTree, error)
- func (r *RecipeRepository) CreateTag(tag *models.Tag) error
- func (r *RecipeRepository) DeleteRecipe(recipeID uint) error
- func (r *RecipeRepository) FindTagByName(tagName string) (*models.Tag, error)
- func (r *RecipeRepository) GetActiveNode(treeID uint) (*models.RecipeNode, error)
- func (r *RecipeRepository) GetNodeAncestors(nodeID uint) ([]models.RecipeNode, error)
- func (r *RecipeRepository) GetNodeByID(nodeID uint) (*models.RecipeNode, error)
- func (r *RecipeRepository) GetNodeChildren(nodeID uint) ([]models.RecipeNode, error)
- func (r *RecipeRepository) GetRecipeByID(recipeID uint) (*models.Recipe, error)
- func (r *RecipeRepository) GetTreeByRecipeID(recipeID uint) (*models.RecipeTree, error)
- func (r *RecipeRepository) GetTreeWithNodes(treeID uint) (*models.RecipeTree, error)
- func (r *RecipeRepository) GetUserRecipes(userID uint, page, pageSize int) ([]models.Recipe, int64, error)
- func (r *RecipeRepository) MaterializeRecipeFromCanonical(recipeID uint, data models.RecipeDef) error
- func (r *RecipeRepository) SetActiveNode(treeID uint, nodeID uint) error
- func (r *RecipeRepository) UpdateRecipeDef(recipe *models.Recipe) error
- func (r *RecipeRepository) UpdateRecipeFromNode(recipeID uint, node *models.RecipeNode) error
- func (r *RecipeRepository) UpdateRecipeImageURL(recipeID uint, imageURL string) error
- func (r *RecipeRepository) UpdateRecipeStatus(recipeID uint, status string) error
- func (r *RecipeRepository) UpdateRecipeTagsAssociation(recipeID uint, newTags []models.Tag) error
- func (r *RecipeRepository) UpdateRecipeTitle(recipe *models.Recipe, title string) error
- type SearchCacheRepo
- type SearchCacheRepository
- func (r *SearchCacheRepository) DeleteStale(maxAge time.Duration) (int64, error)
- func (r *SearchCacheRepository) FindSimilar(embedding []float32, threshold float64, limit int) ([]models.SearchCache, error)
- func (r *SearchCacheRepository) GetByNormalizedQuery(query string) (*models.SearchCache, error)
- func (r *SearchCacheRepository) GetHotQueries(minHits int, maxAge, refreshWindow time.Duration) ([]models.SearchCache, error)
- func (r *SearchCacheRepository) IncrementHitCount(id uint) error
- func (r *SearchCacheRepository) Upsert(entry *models.SearchCache) error
- type UserRepo
- type UserRepository
- func (r *UserRepository) CreateUser(user *models.User) (*models.User, error)
- func (r *UserRepository) GetUserAuthByUsername(username string) (*models.User, error)
- func (r *UserRepository) GetUserByID(userID uint) (*models.User, error)
- func (r *UserRepository) IncrementSubscriptionUsage(userID uint, column string) error
- func (r *UserRepository) ResetSubscriptionUsage(userID uint, nextReset time.Time) error
- func (r *UserRepository) UpdatePersonalization(userID uint, updatedPersonalization *models.Personalization) error
- func (r *UserRepository) UpdateUserEmail(userID uint, email string) error
- func (r *UserRepository) UpdateUserFirstName(userID uint, firstName string) error
- func (r *UserRepository) UpdateUserSettingsKeepScreenAwake(userID uint, keepScreenAwake bool) error
- func (r *UserRepository) UsernameExists(username string) (bool, error)
- type VectorRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PgvectorLiteral ¶
PgvectorLiteral formats a float32 slice as a pgvector literal string: [0.1,0.2,0.3]
Types ¶
type AllergenRepository ¶
AllergenRepository is a repository for interacting with allergen analyses.
func NewAllergenRepository ¶
func NewAllergenRepository(db *gorm.DB) *AllergenRepository
NewAllergenRepository creates a new AllergenRepository.
func (*AllergenRepository) CreateAnalysis ¶
func (r *AllergenRepository) CreateAnalysis(analysis *models.AllergenAnalysis) error
CreateAnalysis creates a new allergen analysis.
func (*AllergenRepository) DeleteAnalysisByRecipeID ¶
func (r *AllergenRepository) DeleteAnalysisByRecipeID(recipeID uint) error
DeleteAnalysisByRecipeID deletes an allergen analysis by recipe ID.
func (*AllergenRepository) GetAnalysisByNodeID ¶
func (r *AllergenRepository) GetAnalysisByNodeID(nodeID uint) (*models.AllergenAnalysis, error)
GetAnalysisByNodeID retrieves an allergen analysis by node ID.
func (*AllergenRepository) GetAnalysisByRecipeID ¶
func (r *AllergenRepository) GetAnalysisByRecipeID(recipeID uint) (*models.AllergenAnalysis, error)
GetAnalysisByRecipeID retrieves an allergen analysis by recipe ID.
func (*AllergenRepository) UpdateAnalysis ¶
func (r *AllergenRepository) UpdateAnalysis(analysis *models.AllergenAnalysis) error
UpdateAnalysis updates an existing allergen analysis.
type CanonicalRecipeRepo ¶
type CanonicalRecipeRepo interface {
GetByID(id uint) (*models.CanonicalRecipe, error)
GetByNormalizedURL(normalizedURL string) (*models.CanonicalRecipe, error)
Upsert(entry *models.CanonicalRecipe) error
IncrementHitCount(id uint) error
GetStaleEntries(maxAge time.Duration) ([]models.CanonicalRecipe, error)
}
CanonicalRecipeRepo is the interface for canonical recipe repository operations.
type CanonicalRecipeRepository ¶
CanonicalRecipeRepository handles canonical recipe CRUD operations.
func NewCanonicalRecipeRepository ¶
func NewCanonicalRecipeRepository(db *gorm.DB) *CanonicalRecipeRepository
NewCanonicalRecipeRepository creates a new CanonicalRecipeRepository.
func (*CanonicalRecipeRepository) GetByID ¶
func (r *CanonicalRecipeRepository) GetByID(id uint) (*models.CanonicalRecipe, error)
GetByID retrieves a canonical recipe by its ID.
func (*CanonicalRecipeRepository) GetByNormalizedURL ¶
func (r *CanonicalRecipeRepository) GetByNormalizedURL(normalizedURL string) (*models.CanonicalRecipe, error)
GetByNormalizedURL performs an exact-match lookup on the normalized URL.
func (*CanonicalRecipeRepository) GetStaleEntries ¶
func (r *CanonicalRecipeRepository) GetStaleEntries(maxAge time.Duration) ([]models.CanonicalRecipe, error)
GetStaleEntries returns canonical entries whose FetchedAt is older than maxAge.
func (*CanonicalRecipeRepository) IncrementHitCount ¶
func (r *CanonicalRecipeRepository) IncrementHitCount(id uint) error
IncrementHitCount atomically increments hit_count and updates last_accessed_at.
func (*CanonicalRecipeRepository) Upsert ¶
func (r *CanonicalRecipeRepository) Upsert(entry *models.CanonicalRecipe) error
Upsert creates or updates a canonical recipe entry, handling race conditions via ON CONFLICT.
type FamilyRepository ¶
FamilyRepository is a repository for interacting with families.
func NewFamilyRepository ¶
func NewFamilyRepository(db *gorm.DB) *FamilyRepository
NewFamilyRepository creates a new FamilyRepository.
func (*FamilyRepository) CreateFamily ¶
func (r *FamilyRepository) CreateFamily(family *models.Family) error
CreateFamily creates a new family.
func (*FamilyRepository) CreateFamilyMember ¶
func (r *FamilyRepository) CreateFamilyMember(member *models.FamilyMember) error
CreateFamilyMember creates a new family member.
func (*FamilyRepository) DeleteFamilyMember ¶
func (r *FamilyRepository) DeleteFamilyMember(id uint) error
DeleteFamilyMember soft-deletes a family member by ID.
func (*FamilyRepository) GetFamilyByOwnerID ¶
func (r *FamilyRepository) GetFamilyByOwnerID(ownerID uint) (*models.Family, error)
GetFamilyByOwnerID retrieves a family by its owner's user ID, preloading members and their dietary profiles.
func (*FamilyRepository) GetFamilyMemberByID ¶
func (r *FamilyRepository) GetFamilyMemberByID(id uint) (*models.FamilyMember, error)
GetFamilyMemberByID retrieves a family member by ID, preloading their dietary profile.
func (*FamilyRepository) GetOrCreateDietaryProfile ¶
func (r *FamilyRepository) GetOrCreateDietaryProfile(memberID uint) (*models.DietaryProfile, error)
GetOrCreateDietaryProfile retrieves the dietary profile for a member, creating one if it doesn't exist.
func (*FamilyRepository) UpdateDietaryProfile ¶
func (r *FamilyRepository) UpdateDietaryProfile(profile *models.DietaryProfile) error
UpdateDietaryProfile updates an existing dietary profile.
func (*FamilyRepository) UpdateFamilyMember ¶
func (r *FamilyRepository) UpdateFamilyMember(member *models.FamilyMember) error
UpdateFamilyMember updates an existing family member.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is an error type for when a resource is not found.
type RecipeRepo ¶
type RecipeRepo interface {
GetUserRecipes(userID uint, page, pageSize int) ([]models.Recipe, int64, error)
GetRecipeByID(recipeID uint) (*models.Recipe, error)
CreateRecipe(recipe *models.Recipe) error
DeleteRecipe(recipeID uint) error
UpdateRecipeTitle(recipe *models.Recipe, title string) error
UpdateRecipeImageURL(recipeID uint, imageURL string) error
UpdateRecipeStatus(recipeID uint, status string) error
UpdateRecipeDef(recipe *models.Recipe) error
FindTagByName(tagName string) (*models.Tag, error)
CreateTag(tag *models.Tag) error
UpdateRecipeTagsAssociation(recipeID uint, newTags []models.Tag) error
CreateRecipeTree(recipeID uint, rootNode *models.RecipeNode) (*models.RecipeTree, error)
GetTreeByRecipeID(recipeID uint) (*models.RecipeTree, error)
GetTreeWithNodes(treeID uint) (*models.RecipeTree, error)
GetActiveNode(treeID uint) (*models.RecipeNode, error)
GetNodeByID(nodeID uint) (*models.RecipeNode, error)
GetNodeChildren(nodeID uint) ([]models.RecipeNode, error)
GetNodeAncestors(nodeID uint) ([]models.RecipeNode, error)
AddNodeToTree(node *models.RecipeNode, setActive bool) error
SetActiveNode(treeID uint, nodeID uint) error
UpdateRecipeFromNode(recipeID uint, node *models.RecipeNode) error
MaterializeRecipeFromCanonical(recipeID uint, data models.RecipeDef) error
}
RecipeRepo is the interface for recipe repository operations.
type RecipeRepository ¶
RecipeRepository is a repository for interacting with recipes.
func NewRecipeRepository ¶
func NewRecipeRepository(db *gorm.DB) *RecipeRepository
NewRecipeRepository creates a new RecipeRepository.
func (*RecipeRepository) AddNodeToTree ¶
func (r *RecipeRepository) AddNodeToTree(node *models.RecipeNode, setActive bool) error
AddNodeToTree adds a new node as a child of the specified parent and optionally sets it as active.
func (*RecipeRepository) CreateRecipe ¶
func (r *RecipeRepository) CreateRecipe(recipe *models.Recipe) error
CreateRecipe creates a new recipe.
func (*RecipeRepository) CreateRecipeTree ¶
func (r *RecipeRepository) CreateRecipeTree(recipeID uint, rootNode *models.RecipeNode) (*models.RecipeTree, error)
CreateRecipeTree creates a new recipe tree with a root node.
func (*RecipeRepository) CreateTag ¶
func (r *RecipeRepository) CreateTag(tag *models.Tag) error
CreateTag creates a new tag.
func (*RecipeRepository) DeleteRecipe ¶
func (r *RecipeRepository) DeleteRecipe(recipeID uint) error
DeleteRecipe deletes a recipe.
func (*RecipeRepository) FindTagByName ¶
func (r *RecipeRepository) FindTagByName(tagName string) (*models.Tag, error)
FindTagByName finds a tag by its name.
func (*RecipeRepository) GetActiveNode ¶
func (r *RecipeRepository) GetActiveNode(treeID uint) (*models.RecipeNode, error)
GetActiveNode retrieves the currently active node for a tree.
func (*RecipeRepository) GetNodeAncestors ¶
func (r *RecipeRepository) GetNodeAncestors(nodeID uint) ([]models.RecipeNode, error)
GetNodeAncestors walks from a node up to the root, returning the chain in root-first order.
func (*RecipeRepository) GetNodeByID ¶
func (r *RecipeRepository) GetNodeByID(nodeID uint) (*models.RecipeNode, error)
GetNodeByID retrieves a single recipe node by ID.
func (*RecipeRepository) GetNodeChildren ¶
func (r *RecipeRepository) GetNodeChildren(nodeID uint) ([]models.RecipeNode, error)
GetNodeChildren retrieves the direct children of a node.
func (*RecipeRepository) GetRecipeByID ¶
func (r *RecipeRepository) GetRecipeByID(recipeID uint) (*models.Recipe, error)
GetRecipeByID retrieves a recipe by its ID.
func (*RecipeRepository) GetTreeByRecipeID ¶
func (r *RecipeRepository) GetTreeByRecipeID(recipeID uint) (*models.RecipeTree, error)
GetTreeByRecipeID retrieves a recipe tree by the recipe ID.
func (*RecipeRepository) GetTreeWithNodes ¶
func (r *RecipeRepository) GetTreeWithNodes(treeID uint) (*models.RecipeTree, error)
GetTreeWithNodes retrieves a recipe tree with all its nodes loaded.
func (*RecipeRepository) GetUserRecipes ¶
func (r *RecipeRepository) GetUserRecipes(userID uint, page, pageSize int) ([]models.Recipe, int64, error)
GetUserRecipes retrieves a paginated list of recipes created by the given user.
func (*RecipeRepository) MaterializeRecipeFromCanonical ¶
func (r *RecipeRepository) MaterializeRecipeFromCanonical(recipeID uint, data models.RecipeDef) error
MaterializeRecipeFromCanonical copies canonical RecipeDef into the recipe's own columns and sets HasDiverged=true, completing copy-on-write.
func (*RecipeRepository) SetActiveNode ¶
func (r *RecipeRepository) SetActiveNode(treeID uint, nodeID uint) error
SetActiveNode sets a specific node as the active node for its tree, deactivating all others.
func (*RecipeRepository) UpdateRecipeDef ¶
func (r *RecipeRepository) UpdateRecipeDef(recipe *models.Recipe) error
UpdateRecipeDef updates the core fields of a recipe.
func (*RecipeRepository) UpdateRecipeFromNode ¶
func (r *RecipeRepository) UpdateRecipeFromNode(recipeID uint, node *models.RecipeNode) error
UpdateRecipeFromNode updates the recipe's core fields from a node's response and sets it as active.
func (*RecipeRepository) UpdateRecipeImageURL ¶
func (r *RecipeRepository) UpdateRecipeImageURL(recipeID uint, imageURL string) error
UpdateRecipeImageURL updates the image URL of a recipe.
func (*RecipeRepository) UpdateRecipeStatus ¶
func (r *RecipeRepository) UpdateRecipeStatus(recipeID uint, status string) error
UpdateRecipeStatus updates the status of a recipe.
func (*RecipeRepository) UpdateRecipeTagsAssociation ¶
func (r *RecipeRepository) UpdateRecipeTagsAssociation(recipeID uint, newTags []models.Tag) error
UpdateRecipeTagsAssociation updates the tags associated with a recipe.
func (*RecipeRepository) UpdateRecipeTitle ¶
func (r *RecipeRepository) UpdateRecipeTitle(recipe *models.Recipe, title string) error
UpdateRecipeTitle updates the title of a recipe.
type SearchCacheRepo ¶
type SearchCacheRepo interface {
GetByNormalizedQuery(query string) (*models.SearchCache, error)
Upsert(entry *models.SearchCache) error
IncrementHitCount(id uint) error
FindSimilar(embedding []float32, threshold float64, limit int) ([]models.SearchCache, error)
GetHotQueries(minHits int, maxAge, refreshWindow time.Duration) ([]models.SearchCache, error)
DeleteStale(maxAge time.Duration) (int64, error)
}
SearchCacheRepo is the interface for search cache repository operations.
type SearchCacheRepository ¶
SearchCacheRepository handles search cache CRUD operations.
func NewSearchCacheRepository ¶
func NewSearchCacheRepository(db *gorm.DB) *SearchCacheRepository
NewSearchCacheRepository creates a new SearchCacheRepository.
func (*SearchCacheRepository) DeleteStale ¶
func (r *SearchCacheRepository) DeleteStale(maxAge time.Duration) (int64, error)
DeleteStale removes entries that haven't been accessed within maxAge.
func (*SearchCacheRepository) FindSimilar ¶
func (r *SearchCacheRepository) FindSimilar(embedding []float32, threshold float64, limit int) ([]models.SearchCache, error)
FindSimilar finds cached entries with embeddings similar to the given vector.
func (*SearchCacheRepository) GetByNormalizedQuery ¶
func (r *SearchCacheRepository) GetByNormalizedQuery(query string) (*models.SearchCache, error)
GetByNormalizedQuery performs an exact-match lookup on the normalized query.
func (*SearchCacheRepository) GetHotQueries ¶
func (r *SearchCacheRepository) GetHotQueries(minHits int, maxAge, refreshWindow time.Duration) ([]models.SearchCache, error)
GetHotQueries returns frequently accessed entries that are approaching staleness.
func (*SearchCacheRepository) IncrementHitCount ¶
func (r *SearchCacheRepository) IncrementHitCount(id uint) error
IncrementHitCount atomically increments hit_count and updates last_accessed_at.
func (*SearchCacheRepository) Upsert ¶
func (r *SearchCacheRepository) Upsert(entry *models.SearchCache) error
Upsert creates or updates a cache entry, handling race conditions via ON CONFLICT.
type UserRepo ¶
type UserRepo interface {
CreateUser(user *models.User) (*models.User, error)
GetUserByID(userID uint) (*models.User, error)
GetUserAuthByUsername(username string) (*models.User, error)
UpdateUserFirstName(userID uint, firstName string) error
UpdateUserEmail(userID uint, email string) error
UpdateUserSettingsKeepScreenAwake(userID uint, keepScreenAwake bool) error
UpdatePersonalization(userID uint, updatedPersonalization *models.Personalization) error
UsernameExists(username string) (bool, error)
}
UserRepo is the interface for user repository operations.
type UserRepository ¶
UserRepository is a repository for interacting with users.
func NewUserRepository ¶
func NewUserRepository(db *gorm.DB) *UserRepository
NewUserRepository creates a new UserRepository.
func (*UserRepository) CreateUser ¶
CreateUser creates a new user.
func (*UserRepository) GetUserAuthByUsername ¶
func (r *UserRepository) GetUserAuthByUsername(username string) (*models.User, error)
GetUserAuthByUsername retrieves a user's authentication information by their username.
func (*UserRepository) GetUserByID ¶
func (r *UserRepository) GetUserByID(userID uint) (*models.User, error)
GetUserByID retrieves a user by their ID.
func (*UserRepository) IncrementSubscriptionUsage ¶
func (r *UserRepository) IncrementSubscriptionUsage(userID uint, column string) error
IncrementSubscriptionUsage atomically increments a usage counter on the subscription row for the given user. column must be one of: "allergen_analyses_used", "web_searches_used", "ai_generations_used".
func (*UserRepository) ResetSubscriptionUsage ¶
func (r *UserRepository) ResetSubscriptionUsage(userID uint, nextReset time.Time) error
ResetSubscriptionUsage zeroes all usage counters and advances the monthly reset timestamp for the given user's subscription.
func (*UserRepository) UpdatePersonalization ¶
func (r *UserRepository) UpdatePersonalization(userID uint, updatedPersonalization *models.Personalization) error
UpdatePersonalization updates a user's personalization settings.
func (*UserRepository) UpdateUserEmail ¶
func (r *UserRepository) UpdateUserEmail(userID uint, email string) error
UpdateUserEmail updates a user's email address.
func (*UserRepository) UpdateUserFirstName ¶
func (r *UserRepository) UpdateUserFirstName(userID uint, firstName string) error
UpdateUserFirstName updates a user's first name.
func (*UserRepository) UpdateUserSettingsKeepScreenAwake ¶
func (r *UserRepository) UpdateUserSettingsKeepScreenAwake(userID uint, keepScreenAwake bool) error
UpdateUserSettingsKeepScreenAwake updates a user's KeepScreenAwake setting.
func (*UserRepository) UsernameExists ¶
func (r *UserRepository) UsernameExists(username string) (bool, error)
UsernameExists checks if a username already exists.
type VectorRepository ¶
VectorRepository handles pgvector similarity search operations.
func NewVectorRepository ¶
func NewVectorRepository(db *gorm.DB) *VectorRepository
NewVectorRepository creates a new VectorRepository.
func (*VectorRepository) FindSimilar ¶
FindSimilar finds recipes similar to the given embedding vector using cosine similarity.
func (*VectorRepository) UpdateEmbedding ¶
func (r *VectorRepository) UpdateEmbedding(recipeID uint, embedding []float32) error
UpdateEmbedding sets the embedding vector for a recipe.