ervu-dashboard-etl/v1_apache-hop dash mapping/ratings/ratings.appear_subpoena.hpl

194 lines
4.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
<info>
<name>ratings.appear_subpoena</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
<parameters>
</parameters>
<capture_transform_performance>N</capture_transform_performance>
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
<created_user>-</created_user>
<created_date>2024/12/24 16:15:10.943</created_date>
<modified_user>-</modified_user>
<modified_date>2024/12/24 16:15:10.943</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
<from>Table input</from>
<to>Get variables</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Get variables</from>
<to>Select values</to>
<enabled>Y</enabled>
</hop>
<hop>
<from>Select values</from>
<to>Insert / update</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Get variables</name>
<type>GetVariable</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<field>
<length>-1</length>
<name>REG_ID</name>
<precision>-1</precision>
<trim_type>none</trim_type>
<type>String</type>
</field>
</fields>
<attributes/>
<GUI>
<xloc>592</xloc>
<yloc>256</yloc>
</GUI>
</transform>
<transform>
<name>Insert / update</name>
<type>InsertUpdate</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<commit>100</commit>
<connection>ervu-dashboard</connection>
<lookup>
<key>
<condition>=</condition>
<field>id_region</field>
<name>REG_ID</name>
</key>
<schema>ratings</schema>
<table>appear_subppoena</table>
<value>
<name>appear_mil_com</name>
<rename>appear_mil_com</rename>
<update>Y</update>
</value>
<value>
<name>appear_mil_com_percent</name>
<rename>appear_mil_com_percent</rename>
<update>Y</update>
</value>
<value>
<name>id_region</name>
<rename>region_id</rename>
<update>N</update>
</value>
</lookup>
<update_bypassed>N</update_bypassed>
<attributes/>
<GUI>
<xloc>976</xloc>
<yloc>256</yloc>
</GUI>
</transform>
<transform>
<name>Select values</name>
<type>SelectValues</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
<select_unspecified>N</select_unspecified>
<meta>
<name>REG_ID</name>
<rename>REG_ID</rename>
<type>String</type>
<length>-2</length>
<precision>-2</precision>
<conversion_mask/>
<date_format_lenient>false</date_format_lenient>
<date_format_locale/>
<date_format_timezone/>
<lenient_string_to_number>false</lenient_string_to_number>
<encoding/>
<decimal_symbol/>
<grouping_symbol/>
<currency_symbol/>
<storage_type/>
</meta>
</fields>
<attributes/>
<GUI>
<xloc>768</xloc>
<yloc>256</yloc>
</GUI>
</transform>
<transform>
<name>Table input</name>
<type>TableInput</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<connection>postgres.subpoena</connection>
<execute_each_row>N</execute_each_row>
<limit>0</limit>
<sql>WITH
total AS (
SELECT
ss.code,
s.department_id
FROM public.subpoena s
JOIN subpoena_status ss
ON s.status_id = ss.id
WHERE ('${VK_ARRAY}' IS NULL
OR '${VK_ARRAY}' = ''
OR s.department_id = ANY (
string_to_array(
trim(both '{}' FROM replace('${VK_ARRAY}', ' ', '')), ','
)::uuid[]
)
)
)
SELECT
'${REG_ID}' AS region_id,
COUNT(*) FILTER (WHERE tt.code IN ('4.1', '4.2')) AS appear_mil_com,
ROUND(
COUNT(*) FILTER (WHERE tt.code IN ('4.1', '4.2'))::NUMERIC / NULLIF(COUNT(*), 0) * 100, 2
) AS appear_mil_com_percent
FROM total tt;</sql>
<variables_active>Y</variables_active>
<attributes/>
<GUI>
<xloc>416</xloc>
<yloc>256</yloc>
</GUI>
</transform>
<transform_error_handling>
</transform_error_handling>
<attributes/>
</pipeline>