Author: mcantelon
Date: Wed Jan 11 13:52:22 2012
New Revision: 10643
Log:
Moved progress display logic into QubitFlatileImport so it's easier to reuse
between import scripts.
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Wed Jan 11 00:04:00 2012
(r10642)
+++ trunk/lib/QubitFlatfileImport.class.php Wed Jan 11 13:52:22 2012
(r10643)
@@ -39,6 +39,7 @@
$this->arrayColumns = array();
$allowedOptions = array(
+ 'rowsUntilProgressDisplay',
'status',
'ignoreColumns',
'columnNames',
@@ -251,7 +252,10 @@
$this->startTimer();
$timerStarted = TRUE;
}
+
print '.';
+ print $this->progressDescription();
+
$this->row($item);
} else {
$this->status['rows']++;
@@ -406,6 +410,27 @@
$this->rowStatusVars = array();
}
+ public function progressDescription()
+ {
+ // return empty string if no intermittant progress display
+ if (!isset($this->rowsUntilProgressDisplay)
+ || !$this->rowsUntilProgressDisplay
+ ) return '.';
+
+ // row count isn't incremented until completion of this closure, so add
one to reflect reality
+ $rowsProcessed = $this->getStatus('rows') + 1 -
$this->getStatus('skippedRows');
+ $memoryUsageMB = round(memory_get_usage() / (1024 * 1024), 2);
+ if (!($rowsProcessed % $this->rowsUntilProgressDisplay))
+ {
+ $elapsed = $this->getTimeElapsed();
+ $elapsedMinutes = round($elapsed / 60, 2);
+ $averageTime = round($elapsed / $rowsProcessed, 2);
+
+ print "\n". $rowsProcessed ." rows processed in ". $elapsedMinutes
+ . " minutes (". $averageTime ." second/row average, ". $memoryUsageMB ."
MB used).\n";
+ }
+ }
+
public function createNote($typeId, $text, $transformationLogic = false)
{
$note = new QubitNote;
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Wed Jan 11 00:04:00 2012
(r10642)
+++ trunk/lib/task/csvImportTask.class.php Wed Jan 11 13:52:22 2012
(r10643)
@@ -124,6 +124,7 @@
// Define import
$import = new QubitFlatfileImport(array(
+ 'rowsUntilProgressDisplay' => $options['rows-until-update'],
/* the status array is a place to put data that should be accessible
from closure logic using the getStatus method */
'status' => array(
@@ -491,23 +492,6 @@
$self->createEvent($term->id, array('actorName' =>
$actorRole['actor']));
}
}
-
- // output progress information
- if ($options = $self->getStatus('options'))
- {
- // row count isn't incremented until completion of this closure,
so add one to reflect reality
- $rowsProcessed = $self->getStatus('rows') + 1 -
$self->getStatus('skippedRows');
- $memoryUsageMB = round(memory_get_usage() / (1024 * 1024), 2);
- if ($options['rows-until-update'] && !($rowsProcessed %
$options['rows-until-update']))
- {
- $elapsed = $self->getTimeElapsed();
- $elapsedMinutes = round($elapsed / 60, 2);
- $averageTime = round($elapsed / $rowsProcessed, 2);
-
- print "\n". $rowsProcessed ." rows processed in ".
$elapsedMinutes
- . " minutes (". $averageTime ." second/row average, ".
$memoryUsageMB ." MB used).\n";
- }
- }
}
}
));
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.