aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_get_reports_list_js
Parameters
Name
Type
Mode
i_prefix_url_pms_file
text
IN (DEFAULT NULL)
Definition
DECLARE strcurrent_propcode text; json_result jsonb; report_interfaces jsonb; sql_text text; BEGIN strcurrent_propcode := fn_current_propcode(); sql_text := format($SQL$ SELECT public.sp_get_reports_list_js(%L, %L, %L)::jsonb, COALESCE( ( SELECT jsonb_object_agg(r.id::text, to_jsonb(r)->'interface_codes') FROM public.reports r WHERE to_jsonb(r)->>'interface_codes' IS NOT NULL ), '{}'::jsonb ) $SQL$, strcurrent_propcode, i_prefix_url_pms_file, fn_current_user()); SELECT result_data, interface_map INTO json_result, report_interfaces FROM dblink(fn_conn_authen(), sql_text) AS params(result_data jsonb, interface_map jsonb); SELECT COALESCE( jsonb_agg( jsonb_set( c.category, '{reports}', public.fn_filter_reports_by_enabled_interfaces( c.category->'reports', report_interfaces ) ) ORDER BY c.category_order ), '[]'::jsonb ) INTO json_result FROM jsonb_array_elements(COALESCE(json_result, '[]'::jsonb)) WITH ORDINALITY AS c(category, category_order); RETURN json_result::json; END;