projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f7cbd3b
)
fix netsapiens CDR import, RT#5226
author
ivan
<ivan>
Thu, 22 Oct 2009 00:28:31 +0000
(
00:28
+0000)
committer
ivan
<ivan>
Thu, 22 Oct 2009 00:28:31 +0000
(
00:28
+0000)
FS/FS/Schema.pm
patch
|
blob
|
history
bin/cdr-netsapiens.import
patch
|
blob
|
history
diff --git
a/FS/FS/Schema.pm
b/FS/FS/Schema.pm
index
ba8dcde
..
cf3a889
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-2149,6
+2149,8
@@
sub tables_hashref {
###
# fields for unitel/RSLCOM/convergent that don't map well to asterisk
# defaults
###
# fields for unitel/RSLCOM/convergent that don't map well to asterisk
# defaults
+ # though these are now used elsewhere:
+ # charged_party, upstream_price, rated_price, carrierid
###
#cdr_type: Usage = 1, S&E = 7, OC&C = 8
###
#cdr_type: Usage = 1, S&E = 7, OC&C = 8
@@
-2191,19
+2193,35
@@
sub tables_hashref {
#NULL, done (or something)
'freesiderewritestatus', 'varchar', 'NULL', 32, '', '',
#NULL, done (or something)
'freesiderewritestatus', 'varchar', 'NULL', 32, '', '',
+ #an indexed place to put big numbers
+ 'cdrid', 'bigint', 'NULL', '', '', '',
+
+ #i should become a table
'cdrbatch', 'varchar', 'NULL', 255, '', '',
'cdrbatch', 'varchar', 'NULL', 255, '', '',
+ #'cdrbatchnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'acctid',
'unique' => [],
'index' => [ [ 'calldate' ],
[ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ],
],
'primary_key' => 'acctid',
'unique' => [],
'index' => [ [ 'calldate' ],
[ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ],
- [ 'accountcode' ], [ 'carrierid' ],
+ [ 'accountcode' ], [ 'carrierid' ],
[ 'cdrid' ],
[ 'freesidestatus' ], [ 'freesiderewritestatus' ],
[ 'cdrbatch' ],
],
},
[ 'freesidestatus' ], [ 'freesiderewritestatus' ],
[ 'cdrbatch' ],
],
},
+ #'cdr_batch' => {
+ # 'columns' => [
+ # 'cdrbatchnum', 'serial', '', '', '', '',
+ # 'cdrbatch', 'varchar', 'NULL', 255, '', '',
+ # '_date', @date_type, '', '',
+ # ],
+ # 'primary_key' => 'cdrbatchnum',
+ # 'unique' => [ [ 'cdrbatch' ] ],
+ # 'index' => [],
+ #},
+
'cdr_termination' => {
'columns' => [
'cdrtermnum', 'bigserial', '', '', '', '',
'cdr_termination' => {
'columns' => [
'cdrtermnum', 'bigserial', '', '', '', '',
diff --git
a/bin/cdr-netsapiens.import
b/bin/cdr-netsapiens.import
index
b3ad5b2
..
8aa4ac0
100755
(executable)
--- a/
bin/cdr-netsapiens.import
+++ b/
bin/cdr-netsapiens.import
@@
-11,7
+11,7
@@
use FS::Record qw(qsearchs);
use FS::part_export;
use FS::cdr;
use FS::part_export;
use FS::cdr;
-$DEBUG =
2
;
+$DEBUG =
1
;
my $user = shift or die &usage;
adminsuidsetup $user;
my $user = shift or die &usage;
adminsuidsetup $user;
@@
-31,8
+31,7
@@
do {
or die dbh->errstr;
$sth->execute or die $sth->errstr;
or die dbh->errstr;
$sth->execute or die $sth->errstr;
- my $time_release = time2str('%Y-%m-%d %x', $sth->fetchrow_arrayref->[0]);
-
+ my $time_release = time2str('%Y-%m-%d %X', $sth->fetchrow_arrayref->[0]);
#retreive CDRs >= this time
my $ns = $part_export->ns_command( 'GET', '/cdr/',
#retreive CDRs >= this time
my $ns = $part_export->ns_command( 'GET', '/cdr/',
@@
-49,11
+48,23
@@
do {
#<a href="/tac2/cdr/20090219201719000016%40SkyNet360.Com">20090219201719000016@SkyNet360.Com</a>
# <form method="post" action="/tac2/cdr/20090219201719000016%40SkyNet360.Com">
while ( $content =~
#<a href="/tac2/cdr/20090219201719000016%40SkyNet360.Com">20090219201719000016@SkyNet360.Com</a>
# <form method="post" action="/tac2/cdr/20090219201719000016%40SkyNet360.Com">
while ( $content =~
- s/^.*?<form class="" method="post" action="\/tac2\/cdr\/(\d+)\%40[^"]*">//is )
+ s/^.*?<form class="" method="post" action="\/tac2\/cdr\/(\d
{4})(\d
+)\%40[^"]*">//is )
{
{
- my $accountcode = $1;
- warn "$accountcode\n" if $DEBUG;
+ my $cdrid = ($1-1900). $2; #2009 -> 109 so we fit in a bigint
+
+ unless ( $cdrs ) { #inefficient
+ my $dsth = dbh->prepare(
+ 'SELECT cdrid FROM cdr WHERE cdrid IS NOT NULL AND cdrid = ?'
+ ) or die dbh->errstr;
+ $dsth->execute($cdrid) or die $dsth->errstr;
+ my $row = $dsth->fetchrow_arrayref;
+ if ( $row && $row->[0] eq $cdrid ) { # == w/ 8 byte int?
+ warn "$cdrid (dup)\n" if $DEBUG > 1;
+ next;
+ }
+ }
+ warn "$cdrid\n" if $DEBUG > 1;
$content =~ s/(.*?)<\/form>//is;
my $cdr_content = $1;
$content =~ s/(.*?)<\/form>//is;
my $cdr_content = $1;
@@
-62,22
+73,23
@@
do {
while ( $cdr_content =~
s/.*?<input name="(\w+)" type="\w+" value="([^"]+)" \/>//is )
{
while ( $cdr_content =~
s/.*?<input name="(\w+)" type="\w+" value="([^"]+)" \/>//is )
{
- warn " $1 => $2\n" if $DEBUG >
1
;
+ warn " $1 => $2\n" if $DEBUG >
2
;
$cdr{$1} = $2;
}
$cdrs++;
my $cdr = new FS::cdr {
$cdr{$1} = $2;
}
$cdrs++;
my $cdr = new FS::cdr {
- 'src' => $cdr{'orig_
sub'}, #orig_from_user?
- 'dst' => $cdr{'
term_sub'},
+ 'src' => $cdr{'orig_
from_user'}, #orig_sub
+ 'dst' => $cdr{'
orig_to_user'}, #term_sub?
'startdate' => FS::cdr::_cdr_date_parse($cdr{'time_start'}),
'enddate' => FS::cdr::_cdr_date_parse($cdr{'time_release'}),
'duration' => $cdr{'duration'},
'billsec' => $cdr{'time_talking'},
#'disposition' =>
'startdate' => FS::cdr::_cdr_date_parse($cdr{'time_start'}),
'enddate' => FS::cdr::_cdr_date_parse($cdr{'time_release'}),
'duration' => $cdr{'duration'},
'billsec' => $cdr{'time_talking'},
#'disposition' =>
- 'accountcode' => $accountcode,
+ #'accountcode' =>
#'charged_party'
#'charged_party'
+ 'cdrid' => $cdrid,
'cdrbatch' => $cdrbatch,
};
'cdrbatch' => $cdrbatch,
};