function ws_search_api_cron in Web Service Data 7
Implements hook_cron().
File
- modules/
ws_search_api/ ws_search_api.module, line 11 - Defines core functionality for web service integration with Search API
Code
function ws_search_api_cron() {
// Selects the expired entities and whom haven't been recently indexed
$result = db_select('ws_search_api_item', 'w')
->fields('w', array(
'entity_type',
'entity_id',
))
->condition('expire', time(), '<')
->execute();
$reindex = array();
while ($record = $result
->fetchAssoc()) {
$reindex[$record['entity_type']][$record['entity_id']] = $record['entity_id'];
}
// Marks them for reindexing
foreach ($reindex as $type => $ids) {
db_delete('ws_search_api_item')
->condition('entity_type', $type)
->condition('entity_id', $ids, 'IN')
->execute();
search_api_track_item_change($type, $ids);
}
}