mirror of https://github.com/BOINC/boinc.git
Fix team cache bug
svn path=/trunk/boinc/; revision=11463
This commit is contained in:
parent
ba1a92c41f
commit
c73cdd3d74
|
@ -43,9 +43,8 @@ function display_team_page($team, $offset, $sort_by) {
|
|||
}
|
||||
row2("Web site", "<a href=$x>$x</a>");
|
||||
}
|
||||
row2("Members (with credit)", team_count_nusers($team->id));
|
||||
row2("Members (with credit)", $team->nusers);
|
||||
|
||||
// Founder object cache
|
||||
$cache_args = "teamid=".$team->id."&founderid=".$team->userid;
|
||||
$cached_data = get_cached_data(TEAM_PAGE_TTL, $cache_args);
|
||||
if ($cached_data){
|
||||
|
@ -178,7 +177,7 @@ function show_team_row($team, $i) {
|
|||
echo"<tr class=row1>
|
||||
<td>$i</td>
|
||||
<td><a href=team_display.php?teamid=$team->id>$team->name</a></td>
|
||||
<td>".team_count_nusers($team->id)."</td>
|
||||
<td>".$team->nusers."</td>
|
||||
<td>$team_expavg_credit</td>
|
||||
<td>$team_total_credit</td>
|
||||
<td>$team->country</td>
|
||||
|
|
|
@ -15,20 +15,22 @@ if (!$offset) $offset=0;
|
|||
$teamid = get_int("teamid");
|
||||
|
||||
if ($offset > 1000) {
|
||||
error_page("Limit exceeded: Only displaying the first 1000 members.");
|
||||
error_page("Limit exceeded: Only displaying the first 1000 members.");
|
||||
}
|
||||
|
||||
db_init();
|
||||
|
||||
// We can only cache team object, as the page is customised to the current user
|
||||
$user = get_logged_in_user(false);
|
||||
|
||||
// We can only cache team object, as the page is customised to the current user
|
||||
$cache_args = "teamid=$teamid&sort_by=$sort_by&offset=$offset";
|
||||
$cached_data = get_cached_data(TEAM_PAGE_TTL, $cache_args);
|
||||
if ($cached_data) {
|
||||
// We found some old but non-stale data, let's use it
|
||||
$team = unserialize($cached_data);
|
||||
} else {
|
||||
// No data was found, generate new data for the cache and store it
|
||||
$team = lookup_team($teamid);
|
||||
$team->nusers = team_count_nusers($team->id);
|
||||
set_cache_data(serialize($team), $cache_args);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,15 @@ if ($offset < ITEM_LIMIT) {
|
|||
} else { //if not do queries etc to generate new data
|
||||
db_init();
|
||||
$data = get_top_teams($offset,$sort_by,$type);
|
||||
|
||||
// We need to calculate nusers before storing into the cache
|
||||
$o = 0;
|
||||
while ($team = $data[$o]) {
|
||||
$data[$o]->nusers = team_count_nusers($team->id);
|
||||
$o++;
|
||||
}
|
||||
set_cache_data(teams_to_store($data),$cache_args); //save data in cache
|
||||
};
|
||||
}
|
||||
} else {
|
||||
error_page("Limit exceeded - Sorry, first ".ITEM_LIMIT." items only");
|
||||
}
|
||||
|
@ -94,5 +101,4 @@ if ($o==ITEMS_PER_PAGE){ //If we aren't on the last page
|
|||
}
|
||||
page_tail();
|
||||
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue