Author: mcantelon
Date: Tue Jan 17 15:10:28 2012
New Revision: 10704

Log:
Cleaned up progress display logic.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Tue Jan 17 14:56:07 2012        
(r10703)
+++ trunk/lib/QubitFlatfileImport.class.php     Tue Jan 17 15:10:28 2012        
(r10704)
@@ -365,10 +365,12 @@
           $timerStarted = TRUE;
         }
 
-        print '.';
+        $this->row($item);
+
+        $this->status['rows']++;
+
         print $this->renderProgressDescription();
 
-        $this->row($item);
       } else {
         $this->status['rows']++;
       }
@@ -390,10 +392,12 @@
   {
     for ($index = 0; $index < count($row); $index++)
     {
-
       // determine what type of data should be in this column
       $columnName = $this->columnNames[$index];
 
+      // stash current column name so handlers can refer to it if need be
+      $this->status['currentColumn'] = $columnName;
+
       // execute row logic
       $logic($this, $index, $columnName, $row[$index]);
     }
@@ -487,9 +491,6 @@
     // process import columns that don't produce child data
     $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
     {
-      // stash current column name so handlers can use it if need be
-      $self->status['currentColumn'] = $columnName;
-
       // if column maps to an attribute, set the attribute
       if (isset($self->columnMap) && isset($self->columnMap[$columnName]))
       {
@@ -529,9 +530,6 @@
   {
     $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
     {
-      // stash current column name so handlers can use it if need be
-      $self->status['currentColumn'] = $columnName;
-
       // if column maps to a property, set the property
       if (isset($self->propertyMap) && isset($self->propertyMap[$columnName]) 
&& trim($value))
       {
@@ -602,9 +600,6 @@
     // process import columns that produce child data (properties and notes)
     $this->rowProcessingAfterSave($row);
 
-    // increment number of completed rows
-    $this->status['rows']++;
-
     // reset row-specific status variables
     $this->rowStatusVars = array();
   }
@@ -626,19 +621,19 @@
   /**
    * Output import progress, time elapsed, and memory usage
    *
-   * @return void
+   * @return string  description of import progress
    */
   public function renderProgressDescription()
   {
-    $output = '';
+    $output = '.';
 
     // return empty string if no intermittant progress display
     if (!isset($this->rowsUntilProgressDisplay)
       || !$this->rowsUntilProgressDisplay
-    ) return '.';
+    ) return $output;
 
     // row count isn't incremented until after this is displayed, so add one 
to reflect reality
-    $rowsProcessed = $this->getStatus('rows') + 1 - 
$this->getStatus('skippedRows');
+    $rowsProcessed = $this->getStatus('rows') - 
$this->getStatus('skippedRows');
     $memoryUsageMB = round(memory_get_usage() / (1024 * 1024), 2);
 
     // if this show should be displayed, display it

-- 
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.

Reply via email to