From 8f35bf476386cfd746ab9fd27d584a4d89d3eeb9 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 14 Feb 2017 08:33:16 -0800 Subject: [PATCH] better scalability for token checks, RT#71513 --- FS/FS/Schema.pm | 21 ++++++++++++++++----- FS/FS/cust_main/Billing_Realtime.pm | 1 + FS/FS/cust_payby.pm | 2 ++ FS/FS/payinfo_Mixin.pm | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 1630f02c3..b6d0f074f 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1620,6 +1620,8 @@ sub tables_hashref { 'ship_mobile', 'varchar', 'NULL', 12, '', '', 'currency', 'char', 'NULL', 3, '', '', + 'is_tokenized', 'char', 'NULL', '1', '', '', + 'geocode', 'varchar', 'NULL', 20, '', '', 'censustract', 'varchar', 'NULL', 20, '', '', # 7 to save space? 'censusyear', 'char', 'NULL', 4, '', '', @@ -1666,6 +1668,7 @@ sub tables_hashref { [ 'archived' ], [ 'ship_locationnum' ], [ 'bill_locationnum' ], + [ 'is_tokenized' ], ], 'foreign_keys' => [ { columns => [ 'agentnum' ], @@ -1718,10 +1721,11 @@ sub tables_hashref { 'paytype', 'varchar', 'NULL', $char_d, '', '', 'payip', 'varchar', 'NULL', 15, '', '', 'locationnum', 'int', 'NULL', '', '', '', + 'is_tokenized', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'custpaybynum', 'unique' => [], - 'index' => [ [ 'custnum' ] ], + 'index' => [ [ 'custnum' ], [ 'is_tokenized' ] ], 'foreign_keys' => [ { columns => [ 'custnum' ], table => 'cust_main', @@ -2415,11 +2419,13 @@ sub tables_hashref { 'manual', 'char', 'NULL', 1, '', '', 'discount_term','int', 'NULL', '', '', '', 'failure_status','varchar','NULL', 16, '', '', + 'is_tokenized', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'paypendingnum', 'unique' => [ [ 'payunique' ] ], 'index' => [ [ 'custnum' ], [ 'status' ], ['paynum'], ['void_paynum'], ['jobnum'], ['invnum'], + [ 'is_tokenized' ], ], 'foreign_keys' => [ { columns => [ 'custnum' ], @@ -2466,7 +2472,8 @@ sub tables_hashref { 'closed', 'char', 'NULL', 1, '', '', 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances 'no_auto_apply', 'char', 'NULL', 1, '', '', - + 'is_tokenized', 'char', 'NULL', 1, '', '', + # cash/check deposit info fields 'bank', 'varchar', 'NULL', $char_d, '', '', 'depositor', 'varchar', 'NULL', $char_d, '', '', @@ -2484,7 +2491,7 @@ sub tables_hashref { 'primary_key' => 'paynum', #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ], 'index' => [ ['custnum'], ['paybatch'], ['payby'], ['_date'], - ['usernum'], + ['usernum'], ['is_tokenized'], ], 'foreign_keys' => [ { columns => [ 'custnum' ], @@ -2522,6 +2529,7 @@ sub tables_hashref { 'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes. 'closed', 'char', 'NULL', 1, '', '', 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances + 'is_tokenized', 'char', 'NULL', 1, '', '', # cash/check deposit info fields 'bank', 'varchar', 'NULL', $char_d, '', '', @@ -2544,7 +2552,9 @@ sub tables_hashref { ], 'primary_key' => 'paynum', 'unique' => [], - 'index' => [ ['custnum'], ['usernum'], ['void_usernum'] ], + 'index' => [ ['custnum'], ['usernum'], ['void_usernum'], + ['is_tokenized'], + ], 'foreign_keys' => [ { columns => [ 'custnum' ], table => 'cust_main', @@ -3086,10 +3096,11 @@ sub tables_hashref { 'processor', 'varchar', 'NULL', $char_d, '', '', # module name 'auth', 'varchar','NULL',16, '', '', # CC auth number 'order_number', 'varchar','NULL',$char_d, '', '', # transaction number + 'is_tokenized', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'refundnum', 'unique' => [], - 'index' => [ ['custnum'], ['_date'], [ 'usernum' ], ], + 'index' => [ ['custnum'], ['_date'], [ 'usernum' ], ['is_tokenized'] ], 'foreign_keys' => [ { columns => [ 'custnum' ], table => 'cust_main', diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index c2cb2e386..0623fbb0d 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -2718,6 +2718,7 @@ sub _token_check_next_recnum { my $sth = $dbh->prepare( 'SELECT '.$tclass->primary_key. ' FROM '.$table. + " WHERE ( is_tokenized IS NULL OR is_tokenized = '' ) ". ' ORDER BY '.$tclass->primary_key. ' LIMIT '.$step. ' OFFSET '.$$offset diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm index 136acf1b6..7e4a465e7 100644 --- a/FS/FS/cust_payby.pm +++ b/FS/FS/cust_payby.pm @@ -359,6 +359,7 @@ sub check { # see parallel checks in check_payinfo_cardtype & payinfo_Mixin::payinfo_check my $cardtype = $self->paycardtype; if ( $self->tokenized ) { + $self->('is_tokenized', 'Y'); #so we don't try to do it again if ( $self->paymask =~ /^\d+x/ ) { $cardtype = cardtype($self->paymask); } else { @@ -559,6 +560,7 @@ sub check_payinfo_cardtype { # see parallel checks in cust_payby::check & payinfo_Mixin::payinfo_check if ( $self->tokenized($payinfo) ) { + $self->set('is_tokenized', 'Y'); #so we don't try to do it again if ( $self->paymask =~ /^\d+x/ ) { $self->set('paycardtype', cardtype($self->paymask)); } else { diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm index 84759cc11..c79729a13 100644 --- a/FS/FS/payinfo_Mixin.pm +++ b/FS/FS/payinfo_Mixin.pm @@ -199,6 +199,7 @@ sub payinfo_check { # see parallel checks in cust_payby::check & cust_payby::check_payinfo_cardtype if ( $self->tokenized ) { + $self->('is_tokenized', 'Y'); #so we don't try to do it again if ( $self->paymask =~ /^\d+x/ ) { $self->set('paycardtype', cardtype($self->paymask)); } else { -- 2.11.0