diff options
author | dirk <beliebige_email_adresse@fidocon.de> | 2011-08-23 23:40:09 +0200 |
---|---|---|
committer | dirk <beliebige_email_adresse@fidocon.de> | 2011-08-23 23:40:09 +0200 |
commit | 5e62a3c27b927d45498f8b56ee7561b2a8204d0d (patch) | |
tree | 86294cc545d8e528e50459a35167a19c3b83a894 /includes/wot.inc.php | |
parent | 920872907c76d3e2c21cb6bfe36842af9121a314 (diff) | |
download | cacert-devel-5e62a3c27b927d45498f8b56ee7561b2a8204d0d.tar.gz cacert-devel-5e62a3c27b927d45498f8b56ee7561b2a8204d0d.tar.xz cacert-devel-5e62a3c27b927d45498f8b56ee7561b2a8204d0d.zip |
bug-827 optimized sql-queries for # of position etc.
Diffstat (limited to 'includes/wot.inc.php')
-rw-r--r-- | includes/wot.inc.php | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/includes/wot.inc.php b/includes/wot.inc.php index a21f78a..50d615f 100644 --- a/includes/wot.inc.php +++ b/includes/wot.inc.php @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ +*/ function query_init ($query) { @@ -34,9 +34,8 @@ function get_number_of_assurances ($userid) { - $res = query_init ("SELECT `users`. *, count(*) AS `list` FROM `users`, `notary` - WHERE `users`.`id` = `notary`.`from` AND `notary`.`method` = 'Face to Face Meeting' AND `from`='".intval($userid)."' - GROUP BY `notary`.`from`"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `method` = 'Face to Face Meeting' AND `from`='".intval($userid)."' "); $row = query_getnextrow($res); return intval($row['list']); @@ -44,9 +43,8 @@ function get_number_of_assurees ($userid) { - $res = query_init ("SELECT `users`. *, count(*) AS `list` FROM `users`, `notary` - WHERE `users`.`id` = `notary`.`to` AND `notary`.`method` = 'Face to Face Meeting' AND `to`='".intval($userid)."' - GROUP BY `notary`.`to`"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `method` = 'Face to Face Meeting' AND `to`='".intval($userid)."' "); $row = query_getnextrow($res); return intval($row['list']); @@ -54,43 +52,41 @@ function get_top_assurer_position ($no_of_assurances) { - $res = query_init ("SELECT count(*) AS `list` FROM `users` - inner join `notary` on `users`.`id` = `notary`.`from` - WHERE `notary`.`method` = 'Face to Face Meeting' - GROUP BY `notary`.`from` HAVING count(*) > '".intval($no_of_assurances)."'"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `method` = 'Face to Face Meeting' + GROUP BY `from` HAVING count(*) > '".intval($no_of_assurances)."'"); return intval(query_get_number_of_rows($res)+1); } function get_top_assuree_position ($no_of_assurees) { - $res = query_init ("SELECT count(*) AS `list` FROM `users` - inner join `notary` on `users`.`id` = `notary`.`to` - WHERE `notary`.`method` = 'Face to Face Meeting' - GROUP BY `notary`.`to` HAVING count(*) > '".intval($no_of_assurees)."'"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `method` = 'Face to Face Meeting' + GROUP BY .`to` HAVING count(*) > '".intval($no_of_assurees)."'"); return intval(query_get_number_of_rows($res)+1); } function get_given_assurances ($userid) { - $res = query_init ("select * from `notary` where `notary`.`from`='".intval($userid)."' and `notary`.`from` != `to` order by `notary`.`id` asc"); + $res = query_init ("select * from `notary` where `from`='".intval($userid)."' and `from` != `to` order by `id` asc"); return $res; } function get_received_assurances ($userid) { - $res = query_init ("select * from `notary` where `notary`.`to`='".intval($userid)."' and `notary`.`from` != `notary`.`to` order by `notary`.`id` asc "); + $res = query_init ("select * from `notary` where `to`='".intval($userid)."' and `from` != `to` order by `id` asc "); return $res; } function get_given_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`from`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `from`='".intval($userid)."' group by points,awarded,method"); return $res; } - + function get_received_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`to`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `to`='".intval($userid)."' group by points,awarded,method"); return $res; } @@ -130,7 +126,7 @@ $awarded = 100; } else - $experience = 0; + $experience = 0; switch ($row['method']) { @@ -288,7 +284,7 @@ $res = get_given_assurances(intval($userid)); while($row = mysql_fetch_assoc($res)) { - $fromuser = get_user (intval($row['to'])); + $fromuser = get_user (intval($row['to'])); calc_experience ($row,$points,$experience,$sum_experience); $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to'])); output_assurances_row (intval($row['id']),$row['date'],$name,intval($row['awarded']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); |