[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5303] branches/1.3



Revision: 5303
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5303&view=rev
Author:   einhverfr
Date:     2012-12-06 09:09:16 +0000 (Thu, 06 Dec 2012)
Log Message:
-----------
Adding db stats post-upgrade and pre/post rebuild-modules

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/LedgerSMB/Database.pm
    branches/1.3/UI/setup/complete.html
    branches/1.3/UI/setup/confirm_operation.html
    branches/1.3/scripts/setup.pl

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-12-06 07:50:28 UTC (rev 5302)
+++ branches/1.3/Changelog	2012-12-06 09:09:16 UTC (rev 5303)
@@ -2,6 +2,9 @@
 Initial Release:  Monday, Oct 12 2011
 Supported Presently
 
+Changelog for 1.3.26
+* Added db statistics post-upgrade and pre/post rebuild (Chris T, 3586113)
+
 Changelog for 1.3.25
 * Fixed internal server errors on LedgerSMB->error() during new() (Chris T)
 * Fixed pricematrix rows not showing where pricegroups are used (Chris T)

Modified: branches/1.3/LedgerSMB/Database.pm
===================================================================
--- branches/1.3/LedgerSMB/Database.pm	2012-12-06 07:50:28 UTC (rev 5302)
+++ branches/1.3/LedgerSMB/Database.pm	2012-12-06 09:09:16 UTC (rev 5303)
@@ -540,12 +540,65 @@
                         log    => "$temp/dblog"});
 }
 
-=item $db->log_from_logfile();
+=item $db->lsmb_info()
 
-Process log file and log relevant pieces via the log classes.
+This routine retrieves general stats about the database and returns the output
+as a hashref with the following key/value pairs:
 
+=over
+
+=item ar_rows 
+
+=item ap_rows
+
+=item gl_rows
+
+=item acc_trans_rows
+
+=item eca_rows
+
+=item oe_rows
+
+=item transactions_rows
+
+=item users_rows
+
+=back
+
 =cut
 
+sub lsmb_info {
+    my ($self) = @_;
+    my @tables = qw(ar ap gl acc_trans entity_credit_account oe transactions 
+                    users);
+    my $retval = {};
+    my $qtemp = 'SELECT count(*) FROM TABLE';
+    my $dbh = 
+    my $dbh = DBI->connect(
+        "dbi:Pg:dbname=$self->{company_name}",  
+         $self->{username}, $self->{password},
+         { AutoCommit => 0, PrintError => $logger->is_warn(), }
+    );
+    for my $t (@tables) {
+        my $query = $qtemp;
+        $query =~ s/TABLE/$t/;
+        my ($count) = $dbh->selectrow_array($query);
+        my $key = $t;
+        $key = 'eca' if $t eq 'entity_credit_account';
+        $retval->{"${key}_count"} = $count;
+    }
+    return $retval;
+}
+    
+
+=item $db->db_tests()
+
+This routine runs general db tests.
+
+TODO
+
+=cut
+
 #TODO
 #
 1;

Modified: branches/1.3/UI/setup/complete.html
===================================================================
--- branches/1.3/UI/setup/complete.html	2012-12-06 07:50:28 UTC (rev 5302)
+++ branches/1.3/UI/setup/complete.html	2012-12-06 09:09:16 UTC (rev 5303)
@@ -9,5 +9,23 @@
 <p><?lsmb text('This database operation has completed successfully.  LedgerSMB may now be used.'); ?></p>
 <p><a href="setup.pl"><?lsmb text('Return to setup') ?></a></p>
 <p><a href="login.pl"><?lsmb text('Start Using LedgerSMB') ?></a></p>
+<?lsmb IF lsmb_info ?>
+<table class='lsmb_info'>
+  <thead>
+  <tr><th colspan="2"><?lsmb text('LedgerSMB Database Statistics') ?></th></tr>
+  <tr><th colspan="2"><?lsmb text('Row counts') ?></th></tr>
+  </thead>
+  <tbody>
+  <tr><th><?lsmb text('AP') ?></th><td><?lsmb lsmb_info.ap_count ?></td></tr>
+  <tr><th><?lsmb text('AR') ?></th><td><?lsmb lsmb_info.ar_count ?></td></tr>
+  <tr><th><?lsmb text('GL') ?></th><td><?lsmb lsmb_info.gl_count ?></td></tr>
+  <tr><th><?lsmb text('Journal Lines') ?></th><td><?lsmb lsmb_info.acc_trans_count ?></td></tr>
+  <tr><th><?lsmb text('Orders') ?></th><td><?lsmb lsmb_info.oe_count ?></td></tr>
+  <tr><th><?lsmb text('Customer/Vendor Accounts') ?></th><td><?lsmb lsmb_info.eca_count ?></td></tr>
+  <tr><th><?lsmb text('Transactions') ?></th><td><?lsmb lsmb_info.transactions_count ?></td></tr>
+  <tr><th><?lsmb text('Users') ?></th><td><?lsmb lsmb_info.users_count ?></td></tr>
+  </tbody>
+</table>
+<?lsmb END ?>
 </body>
 </html>

Modified: branches/1.3/UI/setup/confirm_operation.html
===================================================================
--- branches/1.3/UI/setup/confirm_operation.html	2012-12-06 07:50:28 UTC (rev 5302)
+++ branches/1.3/UI/setup/confirm_operation.html	2012-12-06 09:09:16 UTC (rev 5303)
@@ -57,5 +57,23 @@
 </div>
 <?lsmb END ?>
 </form>
+<?lsmb IF lsmb_info ?>
+<table class='lsmb_info'>
+  <thead>
+  <tr><th colspan="2"><?lsmb text('LedgerSMB Database Statistics') ?></th></tr>
+  <tr><th colspan="2"><?lsmb text('Row counts') ?></th></tr>
+  </thead>
+  <tbody>
+  <tr><th><?lsmb text('AP') ?></th><td><?lsmb lsmb_info.ap_count ?></td></tr>
+  <tr><th><?lsmb text('AR') ?></th><td><?lsmb lsmb_info.ar_count ?></td></tr>
+  <tr><th><?lsmb text('GL') ?></th><td><?lsmb lsmb_info.gl_count ?></td></tr>
+  <tr><th><?lsmb text('Journal Lines') ?></th><td><?lsmb lsmb_info.acc_trans_count ?></td></tr>
+  <tr><th><?lsmb text('Orders') ?></th><td><?lsmb lsmb_info.oe_count ?></td></tr>
+  <tr><th><?lsmb text('Customer/Vendor Accounts') ?></th><td><?lsmb lsmb_info.eca_count ?></td></tr>
+  <tr><th><?lsmb text('Transactions') ?></th><td><?lsmb lsmb_info.transactions_count ?></td></tr>
+  <tr><th><?lsmb text('Users') ?></th><td><?lsmb lsmb_info.users_count ?></td></tr>
+  </tbody>
+</table>
+<?lsmb END ?>
 </body>
 </html>

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2012-12-06 07:50:28 UTC (rev 5302)
+++ branches/1.3/scripts/setup.pl	2012-12-06 09:09:16 UTC (rev 5303)
@@ -128,6 +128,7 @@
                     'Rebuild/Upgrade?'
              );
              $request->{next_action} = 'rebuild_modules';
+             $request->{lsmb_info} = $database->lsmb_info();
          } else {
             $request->{message} = $request->{_locale}->text(
                  'Unknown version found.'
@@ -942,6 +943,7 @@
     
     $database->load_modules('LOADORDER');
     $database->process_roles('Roles.sql');
+    $request->{lsmb_info} = $database->lsmb_info();
     # Credentials set above via environment variables --CT
     #avoid msg commit ineffective with AutoCommit enabled
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",$creds->{login},$creds->{password},{AutoCommit=>0});

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.