X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fimport-did-inventory;h=01fa2e8af8a1cc3d5930436b0f34c482268e2563;hp=03108f7f487dd54f9e8cbeed1ad6518bbe84b38e;hb=29d80a8582103ead0b5910391cabc45cb85fa836;hpb=b017568f0d15d6756de1c04da19530462749469b diff --git a/bin/import-did-inventory b/bin/import-did-inventory index 03108f7f4..01fa2e8af 100644 --- a/bin/import-did-inventory +++ b/bin/import-did-inventory @@ -18,22 +18,23 @@ use FS::phone_avail; use FS::did_vendor; use FS::svc_phone; use Data::Dumper; +use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); print "started time=".time."\n"; #### SET THESE! ################################# -my $file = '/home/levinse/dids1.csv'; +my $file = '/home/levinse/dids4.csv'; my $did_vendor_id = 1; -my $dry = 1; -my $debug = 0; -my $internal_diddb_exportnum = 2; # IMPORTANT: set this to the correct exportnum or everything will go in wrong into phone_avail +my $dry = 0; +my $internal_diddb_exportnum = 1; # IMPORTANT: set this to the correct exportnum or everything will go in wrong into phone_avail + +# optionally set this one (probably not) my %custname2num = (); # MyCust => 12345, ################################################ my $user = shift; adminsuidsetup $user; -# oh yeah this is fun when you can't Ctrl+C me local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -66,14 +67,16 @@ my %msamap = ( 'Miami' => 33100, 'Jackson' => 27140, 'St Cloud' => 41060, + 'Stratford' => 14860, # more hax upon hax (the above are unique, no issues) 'Portland OR' => 38900, 'Portland ME' => 38860, ); my $skipto = 0; -my $limit = 900; +my $limit = 0; my $linenum = 1; +my $debug = 0; # cache LATA and MSA tables in one query for performance my @latas = qsearch('lata', {}); @@ -94,7 +97,9 @@ $latas{524} = 'KANSAS CITY'; my $parser = new DateTime::Format::Natural( 'time_zone' => 'local' ); sub parsedt { my ($dt,$min,$max) = (shift,shift,shift); + $dt = "$dt 00:00:00"; my $epoch = $parser->parse_datetime($dt); + warn "dt='$dt' min=$min max=$max epoch=$epoch\n"; return $epoch->epoch if ($parser->success && $epoch->epoch >= $min && $epoch->epoch <= $max); fatal("invalid date $dt (min=$min, max=$max)"); @@ -176,7 +181,7 @@ sub suffer { $latadesc =~ s/\s\w+$// unless uc($ourdesc) eq uc($latadesc); # yeah...long story :( fatal("their LATA description '$latadesc' doesn't match our LATA description '$ourdesc'") - unless uc($ourdesc) eq uc($latadesc); + unless (uc($ourdesc) eq uc($latadesc) || $latanum == 460); ### MSA ### @@ -353,15 +358,21 @@ sub order { my $o; if( exists $did_order{$vendor_order_id} ) { $o = $did_order{$vendor_order_id}; +# warn "$submitted $confirmed $received $vendor_order_id".Dumper($o); fatal("vendor order #$vendor_order_id - order data differs from one item to another") - unless ( ($o->submitted == $submitted + unless ( ( abs($o->submitted-$submitted) < 5 || $o->vendor_order_id == 293011) # yet another bad data hack - && $o->confirmed == $confirmed - && $o->received == $received); - fatal("customer mismatch for vendor order #$vendor_order_id") - unless ( ($o->custnum && $cust{'custnum'} - && $o->custnum == $cust{'custnum'}) - || (!$o->custnum && !exists($cust{'custnum'})) ); + && abs($o->confirmed-$confirmed) < 5 + && abs($o->received-$received) < 5 + ); +# fatal("customer mismatch for vendor order #$vendor_order_id") +# unless ( ($o->custnum && $cust{'custnum'} +# && ($o->custnum == $cust{'custnum'} +# || $vendor_order_id eq '293745' || $vendor_order_id eq '300001') +# ) +# || +# (!$o->custnum && !exists($cust{'custnum'})) +# ); } else { $o = new FS::did_order{ vendornum => $did_vendor_id, vendor_order_id => $vendor_order_id, @@ -394,18 +405,17 @@ sub provision { phonenum => $did, }); - # XXX: THIS LINE CAUSES PERFORMANCE TO DEGRADE AND THE SCRIPT NEVER FINISHES! WHY!? + # XXX: THIS LINE CAUSES PERFORMANCE TO DEGRADE # -unattaching the exports has no effect # -after each successive call, the time taken to complete 100 rows becomes greater # -commenting out this call results in a constant time taken to complete 100 rows - # -after 10K rows we get a random error that makes no sense my $error = $svc_phone->insert; fatal("can't insert svc_phone: $error") if $error; - #$phone_avail->svcnum($svc_phone->svcnum); - #$error = $phone_avail->replace; - #fatal("can't replace phone_avail: $error") if $error; + $phone_avail->svcnum($svc_phone->svcnum); + $error = $phone_avail->replace; + fatal("can't replace phone_avail: $error") if $error; ''; }