Forráskód Böngészése

Merge pull request #1181 from dsenalik/1180-tv3-bulk_loader_line_count

1180 tv3 bulk loader line count
Stephen Ficklin 4 éve
szülő
commit
8819aad14c

+ 2 - 2
tripal_bulk_loader/includes/tripal_bulk_loader.chado_node.inc

@@ -91,7 +91,7 @@ function tripal_bulk_loader_form($node, $form_state) {
   $form['loader']['has_header'] = [
     '#type' => 'radios',
     '#title' => t('File has a Header'),
-    '#options' => [1 => 'Yes', 2 => 'No'],
+    '#options' => [1 => 'Yes', 0 => 'No'],
     '#weight' => -7,
     '#default_value' => (isset($node->file_has_header)) ? $node->file_has_header : 1,
   ];
@@ -408,4 +408,4 @@ function tripal_bulk_loader_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 10 - 3
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -164,10 +164,14 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
     $total_lines++;
   }
   fclose($handle);
+  // do not count header line in the non-blank line count
+  if (($total_lines) and (preg_match('/(t|true|1)/', $node->file_has_header))) {
+    $total_lines--;
+  }
 
   // Correct for files with a single line and no enter character.
   $total_lines = ($total_lines == 0) ? 1 : $total_lines;
-  print "File: " . $node->file . " (" . $total_lines . " lines)\n";
+  print "File: " . $node->file . " (" . $total_lines . " lines with data)\n";
 
   //print "\nClearing all prepared statements from previous runs of this loader...\n";
   //tripal_core_chado_clear_prepared('_'.$node->nid.'_');
@@ -397,7 +401,10 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
 
         // percentage of lines processed for the current group
         $group_progress = round(($num_lines / $total_lines) * 100);
-        tripal_bulk_loader_progress_bar($num_lines, $total_lines);
+        // don't show progress for the last line, that is printed at the end of this function
+        if ($num_lines < $total_lines) {
+          tripal_bulk_loader_progress_bar($num_lines, $total_lines);
+        }
 
         // percentage of lines processed for all groups
         // <previous group index> * 100 + <current group progress>
@@ -476,7 +483,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       $loaded_without_errors = FALSE;
       break;
     }
-    tripal_bulk_loader_progress_bar($total_lines, $total_lines);
+    tripal_bulk_loader_progress_bar($num_lines, $total_lines);
     tripal_bulk_loader_progress_file_track_job($job_id, FALSE, FALSE, TRUE);
   } //end of foreach constant set