Skip to content
Permalink
Browse files

Add a progress bar to the passive analytics data export functions.

  • Loading branch information...
perlDreamer committed Oct 13, 2011
1 parent 40c6157 commit 82603b29c73710f6993e52cc17c28f7a9f2189e1
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/WebGUI/PassiveAnalytics/Flow.pm
@@ -13,6 +13,7 @@ use WebGUI::Workflow;
use WebGUI::Workflow::Instance;
use WebGUI::User;
use WebGUI::Text;
use WebGUI::ProgressBar;

=head1 NAME
@@ -84,15 +85,26 @@ The name of the file to create inside the storage object.

sub exportSomething {
my ($session, $sth, $filename) = @_;
my $pb = WebGUI::ProgressBar->new($session);
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
$pb->start($i18n->get('export label'), $session->url->extras('adminConsole/passiveAnalytics.png'));
$pb->update($i18n->get('Creating column headers'));
my $storage = WebGUI::Storage->createTemp($session);
my @columns = $sth->getColumnNames;
my $csvData = WebGUI::Text::joinCSV( @columns ). "\n";
$pb->update($i18n->get('Writing data'));
my $rowCounter=0;
while (my $row = $sth->hashRef()) {
my @row = @{ $row }{@columns};
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
if (! ++$rowCounter % 25) {
$pb->update($i18n->get('Writing data'));
}
}
$storage->addFileFromScalar($filename, $csvData);
$session->http->setRedirect($storage->getUrl($filename));
$pb->update(sprintf q|<a href="%s">%s</a>|, $session->url->page('op=passiveAnalytics;func=editRuleflow'), sprintf($i18n->get('Return to %s'), $i18n->get('Passive Analytics','PassiveAnalytics')));
return $pb->finish($storage->getUrl($filename));
}

#-------------------------------------------------------------------

0 comments on commit 82603b2

Please sign in to comment.
You can’t perform that action at this time.