FIX getTermWeight
This commit is contained in:
parent
da637c83de
commit
e4ffb99b54
1 changed files with 5 additions and 5 deletions
|
@ -105,11 +105,11 @@ class RelatedRorController extends ControllerBase {
|
|||
}
|
||||
|
||||
private function getTermWeight(int $termid): int {
|
||||
$term = \Drupal\node\Entity\Term::load($termid);
|
||||
$term = \Drupal\taxonomy\Entity\Term::load($termid);
|
||||
$query = \Drupal::database()->select('taxonomy_index', 'ti');
|
||||
$query->fields('ti', ['nid']);
|
||||
$query->condition('ti.tid', $term_id);
|
||||
$cnt = $query->execute()->rowCount();
|
||||
$query->condition('ti.tid', $termid);
|
||||
$cnt = $query->countQuery()->execute()->fetchField();
|
||||
if($cnt < 100) {
|
||||
return 2;
|
||||
}
|
||||
|
@ -120,8 +120,8 @@ class RelatedRorController extends ControllerBase {
|
|||
$orig_tags = array_map(function($t) { return $t['target_id']; }, $orig['field_tags']);
|
||||
$other_tags = array_map(function($t) { return $t['target_id']; }, $other['field_tags']);
|
||||
$both = array_intersect($orig_tags, $other_tags);
|
||||
$weighted = array_map($this->getTermWeight, $both);
|
||||
return array_sum($weighted);
|
||||
$weighted = array_map([$this, 'getTermWeight'], $both);
|
||||
return array_sum($weighted) || 0;
|
||||
}
|
||||
|
||||
private function cachedJsonResp(array $data): Response {
|
||||
|
|
Loading…
Reference in a new issue