public static function LingotekSync::getTargetCountByDocumentIds in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.4 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getTargetCountByDocumentIds()
- 7.5 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getTargetCountByDocumentIds()
- 7.6 lib/Drupal/lingotek/LingotekSync.php \LingotekSync::getTargetCountByDocumentIds()
File
- lib/
Drupal/ lingotek/ LingotekSync.php, line 632 - LingotekSync
Class
- LingotekSync
- A utility class for Lingotek Syncing.
Code
public static function getTargetCountByDocumentIds($document_ids) {
if (empty($document_ids)) {
return;
}
if (!is_array($document_ids)) {
$document_ids = array(
$document_ids,
);
}
$subquery = db_select('lingotek_entity_metadata', 'l1')
->fields('l1', array(
'entity_id',
))
->condition('l1.entity_type', 'node')
->condition('l1.entity_key', 'document_id')
->condition('l1.value', $document_ids, 'IN');
$query = db_select('lingotek_entity_metadata', 'l');
$query
->addField('l', 'entity_id', 'nid');
$query
->condition('l.entity_type', 'node');
$query
->condition('l.entity_key', 'target_sync_status_%', 'LIKE');
$query
->condition('l.entity_id', $subquery, 'IN');
$query
->addExpression('COUNT(l.entity_key)', 'targets');
$query
->groupBy('l.entity_id');
$result = $query
->execute()
->fetchAllAssoc('nid');
return $result;
}