From: niekt0 Date: Wed, 16 Feb 2011 01:45:18 +0000 (+0100) Subject: node weights update X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=c7049b26840bbdfcbc8bcde3c565d8f987e067ce;p=mirrors%2FKyberia-bloodline.git node weights update --- diff --git a/wwwroot/backend/mysql/test.sql b/wwwroot/backend/mysql/test.sql index 1d2b754..893b92d 100644 --- a/wwwroot/backend/mysql/test.sql +++ b/wwwroot/backend/mysql/test.sql @@ -1,24 +1,20 @@ drop procedure if exists k_neurons; drop function if exists k_get_node_weigth; - delimiter // - create function k_get_node_weigth (node INT, user INT) returns DOUBLE BEGIN declare vector,node2,len,n_owner,offset int; declare final,n_weight,o_weight,s_weight double; select node_vector into vector from nodes where node_id = node; - set final = 1; /* select k from nodes into final where node_id = node;*/ set len = length(vector); set offset = 1; WHILE offset < len DO - /* XXX node length is hardcoded */ - set node2 = substring(node2,offset,8); + set node2 = substring(vector,offset,8); set offset = offset + 8; /* weigths from user to: - all nodes from node to root node @@ -29,20 +25,21 @@ BEGIN select synapse_weight into s_weight from neurons where src=user and dst=node2; select synapse_weight into o_weight from neurons where src=user and dst=n_owner; - if o_weight = NULL then set o_weight=1; end if; - if s_weight = NULL then set s_weight=1; end if; - if n_weight = NULL then set n_weight=1; end if; + if o_weight = NULL or o_weight=0 then set o_weight=1; end if; + if s_weight = NULL or s_weight=0 then set s_weight=1; end if; + if n_weight = NULL or n_weight=0 then set n_weight=1; end if; set final = final * s_weight * o_weight * n_weight; END WHILE; - RETURN final; END// - create procedure k_neurons () begin - select k,node_id,node_name from nodes where k>0 - and node_created>now()-interval 20 day order by k_get_node_weigth(node_id,904) desc; -end// +-- select k_get_node_weigth(node_id,904) from nodes where k>0 +-- and node_created>now()-interval 20 day; + select k,node_id,node_name,k_get_node_weigth(node_id,904) from nodes where k>0 + and node_created>now()-interval 20 day; +-- select * from tmp_table order by k_weight desc; +end// delimiter ;