function recommender_debug_table in Recommender API 6.2
File
- ./
recommender.module, line 371
Code
function recommender_debug_table($app_name, $simpred, $un1, $un2) {
$app_id = recommender_get_app_id($app_name);
// load data
if ($simpred == 0) {
$sql = "SELECT mouse1_id un1, mouse2_id un2, similarity score FROM {recommender_similarity} WHERE app_id=%s ORDER BY mouse1_id, mouse2_id";
}
else {
if ($simpred == 1) {
$sql = "SELECT mouse_id un1, cheese_id un2, prediction score FROM {recommender_prediction} WHERE app_id=%s ORDER BY mouse_id, cheese_id";
}
}
$result = db_query($sql, $app_id);
// load users
$users = array();
$u_result = db_query("SELECT uid, name FROM {users}");
while ($u = db_fetch_array($u_result)) {
$users[$u['uid']] = $u['name'];
}
// load nodes
$nodes = array();
$n_result = db_query("SELECT nid, title FROM {node}");
while ($n = db_fetch_array($n_result)) {
$nodes[$n['nid']] = $n['title'];
}
$un1_content = $un1 ? $nodes : $users;
$un2_content = $un2 ? $nodes : $users;
$un1_header = $un1 ? 'node' : 'user';
$un2_header = $un2 ? 'node' : 'user';
$header = array(
$un1_header,
$un2_header,
'score',
);
$rows = array();
while ($record = db_fetch_array($result)) {
$r = array();
$r[] = l($un1_content[$record['un1']], "{$un1_header}/{$record['un1']}");
$r[] = l($un2_content[$record['un2']], "{$un2_header}/{$record['un2']}");
$r[] = $record['score'];
$rows[] = $r;
}
return theme('table', $header, $rows);
}