[freeside-commits] freeside/FS/FS cdr.pm,1.53,1.53.2.1
Ivan,,,
ivan at wavetail.420.am
Wed Nov 18 23:06:12 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv27320
Modified Files:
Tag: FREESIDE_1_9_BRANCH
cdr.pm
Log Message:
format CDRs durations as NNm MMs instead of NN.MMm, RT#6316
Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.53
retrieving revision 1.53.2.1
diff -u -d -r1.53 -r1.53.2.1
--- cdr.pm 15 Sep 2009 23:13:34 -0000 1.53
+++ cdr.pm 19 Nov 2009 07:06:10 -0000 1.53.2.1
@@ -1,7 +1,7 @@
package FS::cdr;
use strict;
-use vars qw( @ISA @EXPORT_OK $DEBUG );
+use vars qw( @ISA @EXPORT_OK $DEBUG $me );
use Exporter;
use Tie::IxHash;
use Date::Parse;
@@ -13,11 +13,13 @@
use FS::cdr_type;
use FS::cdr_calltype;
use FS::cdr_carrier;
+use FS::cdr_batch;
@ISA = qw(FS::Record);
@EXPORT_OK = qw( _cdr_date_parser_maker _cdr_min_parser_maker );
$DEBUG = 0;
+$me = '[FS::cdr]';
=head1 NAME
@@ -193,7 +195,8 @@
'svcnum' => 'Freeside service',
'freesidestatus' => 'Freeside status',
'freesiderewritestatus' => 'Freeside rewrite status',
- 'cdrbatch' => 'Batch',
+ 'cdrbatch' => 'Legacy batch',
+ 'cdrbatchnum' => 'Batch',
},
};
@@ -505,7 +508,9 @@
if ( $opt{minutes} ) {
$opt{minutes}. ( $opt{granularity} ? 'm' : ' call' );
} else {
- sprintf('%.2fm', $cdr->billsec / 60 );
+ #config if anyone really wants decimal minutes back
+ #sprintf('%.2fm', $cdr->billsec / 60 );
+ int($cdr->billsec / 60).'m '. ($cdr->billsec % 60).'s';
}
};
@@ -814,6 +819,37 @@
# @columns = map { s/^ +//; $_; } @columns;
# }
+# _ upgrade_data
+#
+# Used by FS::Upgrade to migrate to a new database.
+
+sub _upgrade_data {
+ my ($class, %opts) = @_;
+
+ warn "$me upgrading $class\n" if $DEBUG;
+
+ my $sth = dbh->prepare(
+ 'SELECT DISTINCT(cdrbatch) FROM cdr WHERE cdrbatch IS NOT NULL'
+ ) or die dbh->errstr;
+
+ $sth->execute or die $sth->errstr;
+
+ my %cdrbatchnum = ();
+ while (my $row = $sth->fetchrow_arrayref) {
+ my $cdr_batch = new FS::cdr_batch { 'cdrbatch' => $row->[0] };
+ my $error = $cdr_batch->insert;
+ die $error if $error;
+ $cdrbatchnum{$row->[0]} = $cdr_batch->cdrbatchnum;
+ }
+
+ $sth = dbh->prepare('UPDATE cdr SET cdrbatch = NULL, cdrbatchnum = ? WHERE cdrbatch IS NOT NULL AND cdrbatch = ?') or die dbh->errstr;
+
+ foreach my $cdrbatch (keys %cdrbatchnum) {
+ $sth->execute($cdrbatchnum{$cdrbatch}, $cdrbatch) or die $sth->errstr;
+ }
+
+}
+
=back
=head1 BUGS
More information about the freeside-commits
mailing list