tripal_bulk_loader.drush.inc 1.5 KB

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