From ea8ec237eef63c13011de76d414425ce13ce884d Mon Sep 17 00:00:00 2001 From: niekt0 Date: Mon, 14 Mar 2011 00:11:28 +0100 Subject: [PATCH] k_neurons update --- wwwroot/backend/mysql/backend.inc | 2 +- wwwroot/backend/mysql/functions.sql | 2 +- .../node_methodz/function.get_k_neurons.php | 33 +++++++------------ 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/wwwroot/backend/mysql/backend.inc b/wwwroot/backend/mysql/backend.inc index c8b3218..06cea4d 100644 --- a/wwwroot/backend/mysql/backend.inc +++ b/wwwroot/backend/mysql/backend.inc @@ -334,7 +334,7 @@ function get_k_neurons($user_id,$interval) { $q="call k_neurons('$user_id','$interval')"; $set=$db->query($q); - $set->next(); +// $set->next(); return $set; } diff --git a/wwwroot/backend/mysql/functions.sql b/wwwroot/backend/mysql/functions.sql index d8355ea..14bb0f5 100644 --- a/wwwroot/backend/mysql/functions.sql +++ b/wwwroot/backend/mysql/functions.sql @@ -37,7 +37,7 @@ END// create procedure k_neurons ( IN user_id INT, IN day_int INT) BEGIN if day_int = NULL or day_int = 0 then set day_int=20; end if; - select k,node_id,node_name,(k_get_node_weigth(node_id,user_id)*k) as weight_k from nodes where k>0 + select *,(k_get_node_weigth(node_id,user_id)*k) as weight_k from nodes where k>0 and node_created>now()-interval day_int day order by weight_k desc; END// diff --git a/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php b/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php index 394167d..ba04b1a 100644 --- a/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php +++ b/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php @@ -3,36 +3,27 @@ function smarty_function_get_k_neurons($params,&$smarty) { global $db,$node; - if (is_numeric($params['offset'])) $offset=$params['offset']; - else $offset=0; - if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount']; - else $listing_amount=DEFAULT_LISTING_AMOUNT; - if (!is_numeric($_POST['interval'])) $interval=1; - else $interval = $_POST['interval']; - if ($params['vector']) { + if (isset($params['offset']) && (is_numeric($params['offset']))) { + $offset=$params['offset']; + } else {$offset=0;} + if (isset($params['listing_amount']) && (is_numeric($params['listing_amount']))) { + $listing_amount=$params['listing_amount']; + } else {$listing_amount=DEFAULT_LISTING_AMOUNT;} + if (isset($_POST['interval']) && (is_numeric($_POST['interval']))) { + $interval= $_POST['interval']; + } else {$interval = 1;} + if (isset($params['vector']) && ($params['vector'])) { $vector=$params['vector']; $interval=365; - } - else $vector="00"; - -// XXX move to backend + } else {$vector="00";} -/*$q="select nodes.*,parent.node_name as parent_name,users.login as creator - from nodes left join nodes as parent on nodes.node_parent=parent.node_id - left join users on users.user_id=nodes.node_creator where nodes.node_created>now()-interval $interval day - and nodes.node_vector like '$vector%' and nodes.k>0 and nodes.node_system_access!='private' order by nodes.k desc limit $offset,$listing_amount"; -*/ - $q="select COUNT(I.node_id) as count,length(concat(nodes.node_vector)) as vector_depth,nodes.*,nodes.node_creator as node_owner_id,creator.node_name as owner, node_parent.node_name as node_parent_name from I left join nodes on nodes.node_id=I.node_id left join nodes as creator on creator.node_id=nodes.node_creator left join nodes as node_parent on nodes.node_parent=node_parent.node_id where cas>NOW()-INTERVAL 1 HOUR and nodes.node_system_access='public' and nodes.node_vector like '00%' GROUP BY I.node_id ORDER BY count desc"; -// $q="select nodes.*,'foter' as parent_name,'niekt0' as creator from nodes where node_id=4738126"; + $set=nodes::getKNeurons($params['user_id'],20); // XXX offset - $set=$db->query($q); while ($set->next()) { $k_array[]=$set->getRecord(); } -// XXX backend end - $smarty->assign('get_k_neurons',$k_array); } ?> -- 2.30.2