function _recommender_generic_top in Recommender API 6.3
Same name and namespace in other branches
- 7.3 recommender.module \_recommender_generic_top()
- 7.4 recommender.module \_recommender_generic_top()
2 calls to _recommender_generic_top()
- recommender_top_prediction in ./
recommender.module - Return a list of items that are top prediction for $id
- recommender_top_similarity in ./
recommender.module - Return a list of items that are top similar with $id
File
- ./
recommender.module, line 121 - Providing generic recommender system algorithms.
Code
function _recommender_generic_top($app_name, $id, $top_n, $table, $test_func = NULL) {
$app_id = recommender_app_load($app_name, TRUE);
$list = array();
$result = db_query_range("SELECT target_eid id, score FROM {$table} WHERE app_id = %d AND source_eid = %d\n ORDER BY score DESC, updated DESC, target_eid ASC", 0, TOP_N_LIMIT, $app_id, $id);
while (($item = db_fetch_array($result)) && count($list) < $top_n) {
if ($test_func === NULL || call_user_func($test_func, $item)) {
$list[] = $item;
}
}
return $list;
}