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

Merge branch 'fix/filtered-combination' into 'main'

조합 필터링 로직 수정

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