diff --git a/.gitignore b/.gitignore index b8b206a..1df7b57 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules/* .env *.log *.pem -.vscode/ \ No newline at end of file +.vscode/ +*.swp diff --git a/database/interface/map_values/report_unmapped_recs.sql b/database/interface/map_values/report_unmapped_recs.sql index 8ef5899..e0854e0 100644 --- a/database/interface/map_values/report_unmapped_recs.sql +++ b/database/interface/map_values/report_unmapped_recs.sql @@ -1,12 +1,13 @@ DROP FUNCTION IF EXISTS tps.report_unmapped_recs; CREATE FUNCTION tps.report_unmapped_recs(_srce text) RETURNS TABLE ( - source text, - map text, - ret_val jsonb, - "count" bigint, - recs jsonb - + srce text, + target text, + retval jsonb, + map jsonb, + hist jsonb, + cnt bigint, + recs jsonb ) LANGUAGE plpgsql AS @@ -120,16 +121,16 @@ rx AS ( , agg_to_target_items AS ( SELECT - srce - ,id - ,rec - ,target - ,seq - ,map_intention - ,regex_function - ,target_item_number - ,result_key_name - ,target_json_path + rx.srce + ,rx.id + ,rx.rec + ,rx.target + ,rx.seq + ,rx.map_intention + ,rx.regex_function + ,rx.target_item_number + ,rx.result_key_name + ,rx.target_json_path ,CASE WHEN map_key IS NULL THEN NULL @@ -161,18 +162,18 @@ SELECT FROM rx GROUP BY - srce - ,id - ,rec - ,target - ,seq - ,map_intention - ,regex_function - ,target_item_number - ,result_key_name - ,target_json_path - ,map_key - ,retain_key + rx.srce + ,rx.id + ,rx.rec + ,rx.target + ,rx.seq + ,rx.map_intention + ,rx.regex_function + ,rx.target_item_number + ,rx.result_key_name + ,rx.target_json_path + ,rx.map_key + ,rx.retain_key ) --SELECT * FROM agg_to_target_items LIMIT 100 @@ -180,45 +181,43 @@ GROUP BY , agg_to_target AS ( SELECT - srce - ,id - ,rec - ,target - ,seq - ,map_intention + a.srce + ,a.id + ,a.rec + ,a.target + ,a.seq + ,a.map_intention ,tps.jsonb_concat_obj(COALESCE(map_val,'{}'::JSONB)) map_val ,jsonb_strip_nulls(tps.jsonb_concat_obj(COALESCE(retain_val,'{}'::JSONB))) retain_val FROM - agg_to_target_items + agg_to_target_items a GROUP BY - srce - ,id - ,rec - ,target - ,seq - ,map_intention + a.srce + ,a.id + ,a.rec + ,a.target + ,a.seq + ,a.map_intention ) - - , agg_to_ret AS ( SELECT - srce - ,target - ,seq - ,map_intention - ,map_val - ,retain_val + a.srce + ,a.target + ,a.seq + ,a.map_intention + ,a.map_val + ,a.retain_val ,count(*) "count" ,jsonb_agg(rec) rec FROM - agg_to_target + agg_to_target a GROUP BY - srce - ,target - ,seq - ,map_intention - ,map_val - ,retain_val + a.srce + ,a.target + ,a.seq + ,a.map_intention + ,a.map_val + ,a.retain_val ) , link_map AS ( @@ -240,11 +239,13 @@ FROM v.retval = a.map_val ) SELECT - l.srce - ,l.target - ,l.map_val - ,l."count" - ,l.rec + l.srce srce + ,l.target target + ,l.map_val retval + ,null::jsonb map + ,null::jsonb hist + ,l."count" cnt + ,l.rec recs FROM link_map l WHERE @@ -254,4 +255,4 @@ ORDER BY ,l.target ,l."count" desc; END; -$f$ \ No newline at end of file +$f$