You are here

public function Recommender::topSimilarity in Recommender API 6.2

File

./Recommender.php, line 423

Class

Recommender
The super class for all other Recommender algorithms.

Code

public function topSimilarity($mouse, $topN, $testFunc = NULL) {
  $list = array();

  // TODO: should use pager_query(). this is a temporary solution
  $result = db_query_range("SELECT mouse2_id id, similarity score FROM {recommender_similarity}\n                              WHERE app_id=%d AND mouse1_id=%d AND mouse2_id<>mouse1_id\n                              ORDER BY similarity DESC, created DESC, mouse2_id ASC", $this->appId, $mouse, 0, TOP_N_LIMIT);
  while (($item = db_fetch_array($result)) && count($list) < $topN) {
    if ($testFunc === NULL || call_user_func($testFunc, $item)) {
      $list[] = $item;
    }
  }
  return $list;
}