feat: recognition job context, diary linkage, worker improvements
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -146,6 +146,23 @@ func (r *Repository) FindOrCreateRecipe(ctx context.Context, dishID string, calo
|
||||
return recipeID, true, nil
|
||||
}
|
||||
|
||||
// GetTranslation returns the translated dish name for a given language.
|
||||
// Returns ("", false, nil) if no translation exists yet.
|
||||
func (r *Repository) GetTranslation(ctx context.Context, dishID, lang string) (string, bool, error) {
|
||||
var name string
|
||||
queryError := r.pool.QueryRow(ctx,
|
||||
`SELECT name FROM dish_translations WHERE dish_id = $1 AND lang = $2`,
|
||||
dishID, lang,
|
||||
).Scan(&name)
|
||||
if errors.Is(queryError, pgx.ErrNoRows) {
|
||||
return "", false, nil
|
||||
}
|
||||
if queryError != nil {
|
||||
return "", false, fmt.Errorf("get dish translation %s/%s: %w", dishID, lang, queryError)
|
||||
}
|
||||
return name, true, nil
|
||||
}
|
||||
|
||||
// UpsertTranslation inserts or updates the name translation for a dish in a given language.
|
||||
func (r *Repository) UpsertTranslation(ctx context.Context, dishID, lang, name string) error {
|
||||
_, upsertError := r.pool.Exec(ctx,
|
||||
|
||||
Reference in New Issue
Block a user