Remove the sub-query from the user list, significantly speeds it up.

And, dont' show complete status for user types that don't need it.
This commit is contained in:
dave 2010-03-12 05:53:03 +00:00
parent af4b50ace0
commit a4e5761788

View File

@ -167,7 +167,7 @@ function neweditor()
/* Grab a list of users */ /* Grab a list of users */
$w = array(); $w = array();
foreach($show_types as $t) { foreach($show_types as $t) {
$w [] = "u1.types LIKE '%$t%'"; $w [] = "users.types LIKE '%$t%'";
} }
$where_types = "AND (".join(" OR ", $w).")"; $where_types = "AND (".join(" OR ", $w).")";
@ -179,23 +179,21 @@ function neweditor()
} }
if($show_year == 'current') if($show_year == 'current')
$having_year = "AND u1.year={$config['FAIRYEAR']}"; $having_year = "AND users.year={$config['FAIRYEAR']}";
echo "<table class=\"tableview\">"; echo "<table class=\"tableview\">";
$querystr="SELECT $querystr="SELECT *,MAX(users.year) as MAXYEAR
*
FROM FROM
users u1 users
LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`u1`.`id` LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`users`.`id`
LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`u1`.`id` LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`users`.`id`
LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`u1`.`id` LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`users`.`id`
LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`u1`.`id` LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`users`.`id`
LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`u1`.`id` LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`users`.`id`
WHERE u1.year=( SELECT MAX(`year`) FROM users u2 WHERE u1.uid=u2.uid ) GROUP BY users.uid
GROUP BY uid
HAVING HAVING
u1.deleted='no' users.deleted='no'
$having_year $having_year
$where_types $where_types
$where_complete $where_complete
@ -266,7 +264,9 @@ function neweditor()
echo "</td>"; echo "</td>";
echo "<td>"; echo "<td>";
if($r["{$t}_complete"] == 'yes') { if(in_array($t, array('parent','committee','alumni','mentor','fair'))) {
/* Do nothing, there's nothign to complete */
} else if($r["{$t}_complete"] == 'yes') {
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>"; echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
$completeyes++; $completeyes++;
} else { } else {