Skip to content

Commit 0ff57dc

Browse files
committed
fix: order by severity and resolution
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 7e6f7c9 commit 0ff57dc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • services/libs/data-access-layer/src/osspckgs

services/libs/data-access-layer/src/osspckgs/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,12 @@ export async function getAdvisoriesByPackageId(
810810
const paginationClause = opts ? `LIMIT $(limit) OFFSET $(offset)` : ''
811811

812812
const rows = (await qx.select(
813-
`${cte} SELECT * FROM advisory_data ORDER BY "osvId" ${paginationClause}`,
813+
`${cte} SELECT * FROM advisory_data
814+
ORDER BY
815+
CASE severity WHEN 'critical' THEN 1 WHEN 'high' THEN 2 WHEN 'moderate' THEN 3 WHEN 'low' THEN 4 ELSE 5 END,
816+
CASE resolution WHEN 'open' THEN 1 WHEN 'patched' THEN 2 ELSE 3 END,
817+
"osvId"
818+
${paginationClause}`,
814819
{ packageId, limit: opts?.pageSize, offset: opts ? (opts.page - 1) * opts.pageSize : 0 },
815820
)) as AdvisoryRow[]
816821

0 commit comments

Comments
 (0)