You are here

function hacked_calculate_project_data_drush in Hacked! 6.2

Same name and namespace in other branches
  1. 8.2 hacked.drush.inc \hacked_calculate_project_data_drush()
  2. 7.2 hacked.drush.inc \hacked_calculate_project_data_drush()

Compute the report data for hacked.

WARNING: This function can invoke a batch process and end your current page. So you'll want to be very careful if you call this!

2 calls to hacked_calculate_project_data_drush()
drush_hacked_list_projects in ./hacked.drush.inc
Drush command callback that shows the listing of changed/unchanged projects.
drush_hacked_lock_modified in ./hacked.drush.inc
Lock all of the modified files so that pm-updatecode will not touch them.

File

./hacked.drush.inc, line 83
Hacked drush command.

Code

function hacked_calculate_project_data_drush($projects, $force = FALSE, $redirect = NULL) {
  include_once './includes/batch.inc';

  // Try to get the report form cache if we can.
  $cache = cache_get('hacked:drush:full-report', HACKED_CACHE_TABLE);
  if (!empty($cache->data) && !$force) {
    return $cache->data;
  }

  // Enter a batch to build the report.
  $operations = array();
  foreach ($projects as $project) {
    $operations[] = array(
      'hacked_build_report_batch',
      array(
        $project['short_name'],
      ),
    );
  }
  $batch = array(
    'operations' => $operations,
    'finished' => 'hacked_build_report_batch_finished_drush',
    'file' => drupal_get_path('module', 'hacked') . '/hacked.report.inc',
    'title' => t('Building report'),
  );
  drush_print('Rebuilding Hacked! report');
  batch_set($batch);
  $batch =& batch_get();
  $batch['progressive'] = FALSE;
  drush_backend_batch_process();
  drush_print('Done.');

  // Now we can get the data from the cache.
  $cache = cache_get('hacked:drush:full-report', HACKED_CACHE_TABLE);
  if (!empty($cache->data)) {
    return $cache->data;
  }
  return array();
}