mirror of https://github.com/BOINC/boinc.git
web: code cleanup
Note: the top_*.php pages should be changed so that they cache the entire 10000 items as a unit. Otherwise there could be inconsistency.
This commit is contained in:
parent
aaa0254e4c
commit
853de1f5f0
|
@ -42,14 +42,6 @@ function get_top_hosts($offset, $sort_by) {
|
|||
return BoincHost::enum(null, "order by $sort_order limit $offset, $hosts_per_page");
|
||||
}
|
||||
|
||||
function hosts_to_store($participants){
|
||||
return serialize($participants);
|
||||
}
|
||||
|
||||
function store_to_hosts($data){
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
$sort_by = get_str("sort_by", true);
|
||||
switch ($sort_by) {
|
||||
case "total_credit":
|
||||
|
@ -70,10 +62,10 @@ if ($offset >= ITEM_LIMIT) {
|
|||
$cache_args = "sort_by=$sort_by&offset=$offset";
|
||||
$cacheddata = get_cached_data(TOP_PAGES_TTL, $cache_args);
|
||||
if ($cacheddata){
|
||||
$data = store_to_hosts($cacheddata);
|
||||
$data = unserialize($cacheddata);
|
||||
} else {
|
||||
$data = get_top_hosts($offset,$sort_by);
|
||||
set_cached_data(TOP_PAGES_TTL, hosts_to_store($data), $cache_args);
|
||||
set_cached_data(TOP_PAGES_TTL, serialize($data), $cache_args);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -47,16 +47,6 @@ function get_top_teams($offset, $sort_by, $type){
|
|||
return BoincTeam::enum($type_clause, "order by $sort_order limit $offset, $teams_per_page");
|
||||
}
|
||||
|
||||
// These converter functions are here in case we later decide to use something
|
||||
// else than serializing to save temp data
|
||||
//
|
||||
function teams_to_store($participants){
|
||||
return serialize($participants);
|
||||
}
|
||||
function store_to_teams($data){
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
$sort_by = get_str("sort_by", true);
|
||||
switch ($sort_by) {
|
||||
case "total_credit":
|
||||
|
@ -86,7 +76,7 @@ if ($offset < ITEM_LIMIT) {
|
|||
$cacheddata = get_cached_data(TOP_PAGES_TTL,$cache_args);
|
||||
//If we have got the data in cache
|
||||
if ($cacheddata){
|
||||
$data = store_to_teams($cacheddata); // use the cached data
|
||||
$data = unserialize($cacheddata); // use the cached data
|
||||
} else {
|
||||
//if not do queries etc to generate new data
|
||||
$data = get_top_teams($offset,$sort_by,$type);
|
||||
|
@ -96,7 +86,7 @@ if ($offset < ITEM_LIMIT) {
|
|||
$team->nusers = team_count_members($team->id);
|
||||
}
|
||||
//save data in cache
|
||||
set_cached_data(TOP_PAGES_TTL, teams_to_store($data), $cache_args);
|
||||
set_cached_data(TOP_PAGES_TTL, serialize($data), $cache_args);
|
||||
}
|
||||
} else {
|
||||
error_page(tra("Limit exceeded - Sorry, first %1 items only", ITEM_LIMIT));
|
||||
|
|
Loading…
Reference in New Issue