package storage import ( "context" "dana/internal/domain" ) // PriceSectionsBrief отдаёт опубликованные разделы прайса со счётчиком позиций. // Нужен меню в шапке: полный прайс — это 2400+ позиций, тянуть их туда незачем. func (s *Storage) PriceSectionsBrief(ctx context.Context) ([]domain.PriceSectionBrief, error) { rows, err := s.pool.Query(ctx, ` SELECT ps.id, ps.slug, ps.name, (SELECT count(*) FROM price_items pi WHERE pi.section_id = ps.id AND pi.published) FROM price_sections ps WHERE ps.published ORDER BY ps.sort, ps.name`) if err != nil { return nil, err } defer rows.Close() out := []domain.PriceSectionBrief{} for rows.Next() { var b domain.PriceSectionBrief if err := rows.Scan(&b.ID, &b.Slug, &b.Name, &b.Count); err != nil { return nil, err } out = append(out, b) } return out, rows.Err() }