File tree Expand file tree Collapse file tree
backend/src/api/public/v1/ossprey
services/libs/data-access-layer/src/osspckgs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,11 +24,12 @@ function normalizeToArray(v: unknown): unknown[] | undefined {
2424
2525const scatterQuerySchema = z . object ( {
2626 status : z . preprocess ( normalizeToArray , z . array ( statusEnum ) . min ( 1 ) ) . optional ( ) ,
27+ ecosystem : z . string ( ) . min ( 1 ) . optional ( ) ,
2728} )
2829
2930export async function packageScatterHandler ( req : Request , res : Response ) : Promise < void > {
30- const { status } = validateOrThrow ( scatterQuerySchema , req . query )
31+ const { status, ecosystem } = validateOrThrow ( scatterQuerySchema , req . query )
3132 const qx = await getPackagesQx ( )
32- const points = await listPackagesForScatter ( qx , { status } )
33+ const points = await listPackagesForScatter ( qx , { status, ecosystem } )
3334 ok ( res , { points, total : points . length } )
3435}
Original file line number Diff line number Diff line change @@ -667,9 +667,9 @@ export interface ScatterPoint {
667667
668668export async function listPackagesForScatter (
669669 qx : QueryExecutor ,
670- options : { status ?: string [ ] } = { } ,
670+ options : { status ?: string [ ] ; ecosystem ?: string } = { } ,
671671) : Promise < ScatterPoint [ ] > {
672- const { status } = options
672+ const { status, ecosystem } = options
673673
674674 // 'unassigned' covers packages with no stewardship row (s.id IS NULL) in addition
675675 // to rows explicitly marked unassigned. All other statuses filter via s.status = ANY(...).
@@ -678,6 +678,7 @@ export async function listPackagesForScatter(
678678 const statusFilter = status ?. length
679679 ? `AND (s.status = ANY($(status)::text[])${ includesUnassigned ? ' OR s.id IS NULL' : '' } )`
680680 : ''
681+ const ecosystemFilter = ecosystem ? `AND p.ecosystem = $(ecosystem)` : ''
681682
682683 const rows : Array < {
683684 purl : string
@@ -714,10 +715,11 @@ export async function listPackagesForScatter(
714715 ) r_sc ON true
715716 WHERE p.is_critical = true
716717 ${ statusFilter }
718+ ${ ecosystemFilter }
717719 ORDER BY p.impact DESC NULLS LAST, p.purl ASC
718720 LIMIT 2000
719721 ` ,
720- { status } ,
722+ { status, ecosystem } ,
721723 )
722724
723725 return rows . map ( ( r ) => ( {
You can’t perform that action at this time.
0 commit comments