diff --git a/main.sql b/main.sql index fabe89e..0580eb8 100644 --- a/main.sql +++ b/main.sql @@ -14,6 +14,7 @@ WITH abc AS ( CAST(NULLIF(NULLIF(LOWER(TRIM(thx.summary_risk_score::text)), ''), 'none') AS DOUBLE PRECISION) AS summary_risk_score, CAST(NULLIF(NULLIF(LOWER(TRIM(thx.cpu_clock::text)), ''), 'none') AS DOUBLE PRECISION) AS cpu_clock, CAST(NULLIF(NULLIF(thx.true_ip_first_seen::text, ''), 'None') AS DATE) AS true_ip_first_seen, + NULLIF(NULLIF(LOWER(TRIM(thx.ssn_hash::text)), ''), 'none') AS ssn_hash, CAST(NULLIF(NULLIF(thx.ssn_hash_first_seen::text, ''),'None') AS DATE) AS ssn_hash_first_seen, thx.account_email_attributes, CAST(NULLIF(NULLIF(LOWER(TRIM(thx.tps_ip_latitude::text)), ''), 'none') AS DOUBLE PRECISION) AS tps_ip_latitude, @@ -56,6 +57,7 @@ current_app AS ( application_ssn, application_customer_type, zip, + NULLIF(NULLIF(LOWER(TRIM($input_ssn_hash::text)), ''), 'none') AS ssn_hash, $input_ip_address AS input_ip_address, $input_ip_connection_type AS input_ip_connection_type, $input_ip_isp AS input_ip_isp, @@ -259,7 +261,7 @@ clusters_g2 AS ( input_ip_velocity_population AS ( SELECT cur.current_app_key, - NULLIF(app.application_ssn, '') AS application_ssn, + NULLIF(NULLIF(LOWER(TRIM(thx.ssn_hash::text)), ''), 'none') AS ssn_hash, NULLIF(NULLIF(LOWER(TRIM(up.zip::text)), ''), 'none') AS zip FROM current_app cur JOIN public.thx AS thx @@ -277,7 +279,7 @@ input_ip_velocity_population AS ( SELECT current_app_key, - application_ssn, + ssn_hash, zip FROM current_app WHERE input_ip_address IS NOT NULL @@ -288,8 +290,8 @@ input_ip_velocity AS ( SELECT current_app_key, COUNT(DISTINCT CASE - WHEN LOWER(TRIM(application_ssn::text)) NOT IN ('', 'nan', 'null', 'none', 'n/a') - THEN application_ssn + WHEN LOWER(TRIM(ssn_hash::text)) NOT IN ('', 'nan', 'null', 'none', 'n/a') + THEN ssn_hash ELSE NULL END) AS input_ip_distinct_ssn_24h, COUNT(DISTINCT CASE diff --git a/request_schema.json b/request_schema.json index 10972a1..e2dc69c 100644 --- a/request_schema.json +++ b/request_schema.json @@ -32,6 +32,10 @@ "input_ip_isp": { "type": ["string", "null"], "description": "Current application THX input IP ISP." + }, + "input_ssn_hash": { + "type": ["string", "null"], + "description": "Current application THX SSN hash." } }, "required": []