tripal_bulk_loader.drush.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @file
  4. * Implements drush integration for this module
  5. */
  6. /**
  7. * Implements hook_drush_command().
  8. */
  9. function tripal_bulk_loader_drush_command() {
  10. $items = array();
  11. $items['tripal-loader-progress'] = array(
  12. 'description' => dt('Display the progress of any running tripal bulk loading job.'),
  13. 'aliases' => array('trpload-%'),
  14. );
  15. return $items;
  16. }
  17. /**
  18. * Code ran for the tripal-loader-progress drush command
  19. * Display the progress of any running tripal bulk loading job.
  20. */
  21. function drush_tripal_bulk_loader_tripal_loader_progress() {
  22. // determine the progress of any loading jobs
  23. $sql = "SELECT t.loader_name, t.file, t.job_id FROM {tripal_bulk_loader} t WHERE job_status='Loading...'";
  24. $resource = db_query($sql);
  25. while ($r = db_fetch_object($resource)) {
  26. if ($r->job_id) {
  27. $progress = tripal_bulk_loader_progess_file_get_progress($r->job_id);
  28. if ($progress->num_records > 0 AND $progress->total_percent < 100) {
  29. drush_print(
  30. $r->loader_name . "\n"
  31. . str_repeat("-", 40) . "\n"
  32. . "File:" . $r->file . "\n"
  33. . "Current Constant Set:\n"
  34. . "\tLines processed: " . $progress->num_lines . "\n"
  35. . "\tRecord Inserted: " . $progress->num_records . "\n"
  36. . "\tPercent Complete: " . $progress->percent_file . "\n"
  37. . "Number of Constant Sets fully loaded: " . $progress->num_constant_sets_loaded . "\n"
  38. . "Job Percent Complete: " . $progress->total_percent . "\n"
  39. );
  40. }
  41. }
  42. }
  43. }