Skip to content
Snippets Groups Projects
Commit e87e56d1 authored by Lee WooChang's avatar Lee WooChang
Browse files

fix: 조합 필터링 로직 수정

parent 6bc18cd8
No related branches found
No related tags found
1 merge request!12조합 필터링 로직 수정
Pipeline #10736 failed
...@@ -72,18 +72,24 @@ const PartRepository = { ...@@ -72,18 +72,24 @@ const PartRepository = {
async getFilteredCombinations(queryValues) { async getFilteredCombinations(queryValues) {
const query = ` const query = `
WITH input_parts AS (
SELECT array_agg(unnest) AS required_parts
FROM unnest($1::int[]) AS unnest
),
parts AS (
SELECT SELECT
c.id AS combination_id, combination_id,
array_agg(r.part_id) AS partIds array_agg(part_id ORDER BY part_id) AS existing_parts
FROM combinations c
LEFT JOIN relations r ON c.id = r.combination_id
WHERE r.combination_id IN (
SELECT DISTINCT combination_id
FROM relations FROM relations
WHERE part_id = ANY($1::int[]) GROUP BY combination_id
) )
GROUP BY c.id; SELECT
p.combination_id,
p.existing_parts AS partIds
FROM parts p, input_parts i
WHERE p.existing_parts @> i.required_parts;
`; `;
const result = await pool.query(query, queryValues); const result = await pool.query(query, queryValues);
return result.rows; return result.rows;
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment