You are here

public function MigrationBase::getLastThroughput in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 includes/base.inc \MigrationBase::getLastThroughput()

Retrieve the last throughput for current Migration (items / minute).

Return value

integer

File

includes/base.inc, line 876
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

public function getLastThroughput() {
  $last_throughput = 0;
  $row = db_select('migrate_log', 'ml')
    ->fields('ml', array(
    'starttime',
    'endtime',
    'numprocessed',
  ))
    ->condition('machine_name', $this->machineName)
    ->condition('process_type', 1)
    ->isNotNull('endtime')
    ->orderBy('starttime', 'DESC')
    ->execute()
    ->fetchObject();
  if ($row) {
    $elapsed = ($row->endtime - $row->starttime) / 1000;
    if ($elapsed > 0) {
      $last_throughput = round($row->numprocessed / $elapsed * 60);
    }
  }
  return $last_throughput;
}