<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>checkpoint_raw_info_recruits_success</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>2025/05/21 10:25:24.598</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/05/21 10:25:24.598</modified_date>
  </info>
  <notepads>
    <notepad>
      <backgroundcolorblue>251</backgroundcolorblue>
      <backgroundcolorgreen>232</backgroundcolorgreen>
      <backgroundcolorred>201</backgroundcolorred>
      <bordercolorblue>90</bordercolorblue>
      <bordercolorgreen>58</bordercolorgreen>
      <bordercolorred>14</bordercolorred>
      <fontbold>N</fontbold>
      <fontcolorblue>90</fontcolorblue>
      <fontcolorgreen>58</fontcolorgreen>
      <fontcolorred>14</fontcolorred>
      <fontitalic>N</fontitalic>
      <fontname>Segoe UI</fontname>
      <fontsize>9</fontsize>
      <height>26</height>
      <xloc>528</xloc>
      <yloc>288</yloc>
      <note>определение рекрута и военкомата на котором остановилась загрузка данных</note>
      <width>445</width>
    </notepad>
  </notepads>
  <order>
    <hop>
      <from>Table input</from>
      <to>Table output</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <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>ervu-dashboard</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>WITH 
rows AS (
    SELECT 
	 recruit_id, 
        --ROW_NUMBER() OVER (ORDER BY recruit_id) AS 
        rn_recruit,
        COALESCE(recruitment_id,target_recruitment_id) AS recruitment_id,
        --ROW_NUMBER() OVER (ORDER BY COALESCE(recruitment_id,target_recruitment_id)) AS 
        rn_recruitment
    FROM ervu_dashboard.citizen
    WHERE (recruitment_id is not null or target_recruitment_id is not null) AND recruit_id IS NOT NULL
)
SELECT
    'job_if_err_raw_inf_recr' AS job_name,
    CURRENT_TIMESTAMP AS last_update,
    recruit_id AS last_recruit_id,
    rn_recruit,
    recruitment_id AS last_recruitment_id,
    rn_recruitment,
    'SUCCESS' AS status
FROM rows
WHERE rn_recruitment = (SELECT MAX(rn_recruitment) FROM rows)
ORDER BY rn_recruit DESC
LIMIT 1;</sql>
    <variables_active>N</variables_active>
    <attributes/>
    <GUI>
      <xloc>544</xloc>
      <yloc>384</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table output</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>1000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
</fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_keys>N</return_keys>
    <schema>public</schema>
    <specify_fields>N</specify_fields>
    <table>etl_checkpoints</table>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>960</xloc>
      <yloc>384</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
