You are here

function apachesolr_nan_cron in Apache Solr Not-A-Node 7

Same name and namespace in other branches
  1. 7.2 apachesolr_nan.module \apachesolr_nan_cron()

Implements hook_cron().

Find non-nodes that should be indexed and pass them to solr.

File

./apachesolr_nan.module, line 27
Provides hook and common functions for non-node searching.

Code

function apachesolr_nan_cron() {
  $query = db_select('apachesolr_nan_index_paths', 'p');
  $query
    ->fields('p', array(
    'id',
    'path',
    'description',
    'title',
  ));
  $query
    ->where('(:time - p.last_indexed) > p.frequency', array(
    ':time' => REQUEST_TIME,
  ));
  $results = $query
    ->execute();
  while ($data = $results
    ->fetchAssoc()) {
    apachesolr_nan_process_solr_indexes($data['path'], $data['title'], $data['description'], $data['id']);
    watchdog('ApacheSolr NAN search', 'The apache solr non-node item %id from path %path was indexed.', array(
      '%id' => $data['id'],
      '%path' => $data['path'],
    ));
    $data['last_indexed'] = REQUEST_TIME;
    drupal_write_record('apachesolr_nan_index_paths', $data, array(
      'id',
    ));
  }
}