RULE 5: HOURLY
Wed Jul 06 2022 10:54:03 GMT+0000 (Coordinated Universal Time)
Saved by @shubhangi_burle
-- RULE 5: HOURLY LIMIT ON C2M WALLET TXNS: ROLLING SELECT '2022' AS year, '6' as month, P.rule_name, P.status, 'MIN + FULL' as kyc, P.catg, 'Hourly' as Frequency, P.breaches FROM (SELECT Z.rule_name, Z.catg, SUM(IF(Z.txns >= Z.limit, 1, 0)) AS breaches, Y.status FROM (SELECT 'HML_MERCHANT_PAYMENT_WALLET_TXN_LIMIT' as rule_name, A.senderuserid, A.transaction_id, COUNT(DISTINCT B.transaction_id) AS txns, IF(C.hml_category IS NOT NULL, C.hml_category, 'LOW RISK') AS catg, CASE WHEN C.hml_category = 'HIGH RISK' THEN 5 WHEN C.hml_category = 'MEDIUM RISK' THEN 10 ELSE 15 END AS limit FROM (SELECT DISTINCT senderuserid, transaction_id, updated_date as txnTime from fraud.transaction_details where year(updated_date) = 2022 and month(updated_date) = 6 and sendertype = 'INTERNAL_USER' AND workflowtype = 'CONSUMER_TO_MERCHANT' and pay_transaction_status = 'COMPLETED' AND errorcode = 'SUCCESS' and wallet_flag = 'TRUE')A LEFT JOIN (SELECT DISTINCT senderuserid, transaction_id, updated_date as txnTime from fraud.transaction_details where year(updated_date) = 2022 and month(updated_date) IN (5,6) and sendertype = 'INTERNAL_USER' AND workflowtype = 'CONSUMER_TO_MERCHANT' and pay_transaction_status = 'COMPLETED' AND errorcode = 'SUCCESS' and wallet_flag = 'TRUE')B ON A.senderuserid = B.senderuserid AND ((UNIX_TIMESTAMP(A.txnTime) - UNIX_TIMESTAMP(B.txnTime))/3600) BETWEEN 0 AND 1 AND A.txnTime > B.txnTime LEFT JOIN (SELECT DISTINCT senderuserid, hml_category FROM fraud.hml_classification)C ON A.senderuserid = C.senderuserid GROUP BY A.senderuserid, A.transaction_id, C.hml_category)Z LEFT JOIN (SELECT DISTINCT eventdata_appliedrulesetid as rule_name, eventdata_mode AS status FROM foxtrot_stream.kratos_default WHERE eventdata_actions = 'BLOCK' AND eventdata_appliedrulesetid = 'HML_MERCHANT_PAYMENT_WALLET_TXN_LIMIT' AND year = 2022 AND month = 6)Y ON Z.rule_name = Y.rule_name GROUP BY Z.rule_name, Z.catg, Y.status)P
Comments