feat: recognition job context, diary linkage, worker improvements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
dbastrikin
2026-03-19 22:22:44 +02:00
parent cf69a4a3d9
commit 9357c194eb
5 changed files with 130 additions and 5 deletions

View File

@@ -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,