This commit is contained in:
yash 2024-01-25 23:40:04 +03:00
parent bad50a81cc
commit d0b82dde31
2 changed files with 7 additions and 9 deletions

View File

@ -20,8 +20,6 @@ const (
//TODO //TODO
// cache // cache
// app
// graceful sd
// tests // tests
func main() { func main() {
@ -33,9 +31,9 @@ func main() {
log.Debug("debug messages are enabled") log.Debug("debug messages are enabled")
log.Debug("Application config", slog.Any("config", fmt.Sprintf("%+v", *cfg))) log.Debug("Application config", slog.Any("config", fmt.Sprintf("%+v", *cfg)))
// init app (storage, cache, media storage) // init app
application := app.New(log, cfg) application := app.New(log, cfg)
// start app // start server
go application.HTTPSrv.MustRun() go application.HTTPSrv.MustRun()
// graceful shutdown // graceful shutdown

View File

@ -184,7 +184,7 @@ func (s *Storage) GetRecipe(ctx context.Context, r_id uint) (models.Recipe, erro
ctx, ctx,
"select title, description, image, cooking_time, servings, cal from recipe where id = $1", "select title, description, image, cooking_time, servings, cal from recipe where id = $1",
r_id, r_id,
).Scan(&recipe) ).Scan(&recipe.Title, &recipe.Description, &recipe.Image, &recipe.CookingTime, &recipe.ServingsNum, &recipe.Calories)
if err != nil { if err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
@ -353,10 +353,10 @@ func (s *Storage) GetRecipesByCategory(ctx context.Context, offset, limit int, c
return nil, fmt.Errorf("%s: %w", op, err) return nil, fmt.Errorf("%s: %w", op, err)
} }
err = s.AddRecipeInformation(ctx, &r) // err = s.AddRecipeInformation(ctx, &r)
if err != nil { // if err != nil {
return nil, fmt.Errorf("%s: %w", op, err) // return nil, fmt.Errorf("%s: %w", op, err)
} // }
recipes = append(recipes, r) recipes = append(recipes, r)
} }