You are here

function drush_migrate_status in Migrate 6

Same name and namespace in other branches
  1. 6.2 migrate.drush.inc \drush_migrate_status()
  2. 7.2 migrate.drush.inc \drush_migrate_status()

A simplified version of the Process (dashboard) page

File

./migrate.drush.inc, line 134
Drush support for the migrate module

Code

function drush_migrate_status() {
  $table = array();
  $table[] = array(
    dt('Status'),
    dt('Name'),
    dt('Total'),
    dt('Imported'),
    dt('Unimported'),
  );
  $sql = "SELECT *\n          FROM {migrate_content_sets}\n          ORDER BY weight, contenttype, view_name, view_args";
  $result = db_query($sql);
  while ($row = db_fetch_object($result)) {
    if ($row->status == MIGRATE_STATUS_CLEARING) {
      $status = dt('Clearing');
    }
    elseif ($row->status == MIGRATE_STATUS_IMPORTING) {
      $status = dt('Importing');
    }
    else {
      $status = dt('');
    }
    $view = views_get_view($row->view_name);
    if (!$view) {
      drush_set_error(NULL, dt('View !view does not exist - either (re)create this view, or
        remove the content set using it.', array(
        '!view' => $row->view_name,
      )));
      continue;
    }
    $maptable = migrate_map_table_name($row->mcsid);
    $imported = db_result(db_query('SELECT COUNT(*) FROM {' . $maptable . '}'));

    // If not caching counts, override the saved count with a fresh count
    if (!variable_get('migrate_cache_counts', 0)) {
      $total = _migrate_get_view_count($view, $row->view_args);
    }
    else {
      $total = $row->rowcount;
    }
    $table[] = array(
      $status,
      $row->description,
      $total,
      $imported,
      $total - $imported,
    );
  }
  drush_print_table($table, TRUE);
}