feat(F-093): completed feature

This commit is contained in:
chattie
2026-08-20 21:57:43 +02:00
parent 387e9b2943
commit c56037492d
11 changed files with 168 additions and 52 deletions

View File

@@ -189,7 +189,13 @@ export class PgProductRepository implements ProductRepository {
const countResult = await this.pool.query<{ count: string }>(
q
? `SELECT COUNT(*) FROM catalog_products WHERE name ILIKE $1`
? `SELECT COUNT(*)
FROM catalog_products p
WHERE p.name ILIKE $1
OR EXISTS (
SELECT 1 FROM catalog_product_variants v
WHERE v.product_id = p.id AND v.ean ILIKE $1
)`
: 'SELECT COUNT(*) FROM catalog_products',
q ? [`%${q}%`] : [],
);
@@ -202,6 +208,10 @@ export class PgProductRepository implements ProductRepository {
LEFT JOIN catalog_product_categories pc ON pc.product_id = p.id
LEFT JOIN brands_brands b ON b.id = p.brand_id
WHERE p.name ILIKE $1
OR EXISTS (
SELECT 1 FROM catalog_product_variants v
WHERE v.product_id = p.id AND v.ean ILIKE $1
)
GROUP BY p.id, b.name, b.slug
ORDER BY p.created_at DESC
LIMIT $2 OFFSET $3`