aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
fn_filter_reports_by_enabled_interfaces
Parameters
Name
Type
Mode
i_reports
jsonb
IN
i_report_interfaces
jsonb
IN
Definition
SELECT COALESCE(jsonb_agg(r.report ORDER BY r.report_order), '[]'::jsonb) FROM jsonb_array_elements(COALESCE(i_reports, '[]'::jsonb)) WITH ORDINALITY AS r(report, report_order) CROSS JOIN LATERAL ( SELECT COALESCE(r.report->>'id', r.report->>'report_id') AS report_id ) report_key WHERE report_key.report_id IS NULL OR NOT (COALESCE(i_report_interfaces, '{}'::jsonb) ? report_key.report_id) OR EXISTS ( SELECT 1 FROM jsonb_array_elements_text(i_report_interfaces->report_key.report_id) required(code) JOIN public.interfaces i ON upper(i.code::text) = upper(required.code) WHERE i.enabled );