} if ($user->id == $team->ping_user) { $get_from_db = true; } // Cache the team record, its forum record, its new members, // its admins, and its member counts $cache_args = "teamid={$teamid}"; if (!$get_from_db) { $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 { $get_from_db = true; } } if ($get_from_db) { $team->nusers = BoincUser::count("teamid={$teamid}"); $team->nusers_worked = BoincUser::count("teamid={$teamid} and total_credit>0"); $team->nusers_active = BoincUser::count("teamid={$teamid} and expavg_credit>0.1"); $team->forum = BoincForum::lookup("parent_type=1 and category={$team->id}"); $team->new_members = new_member_list($teamid); $team->admins = admin_list($teamid); $team->founder = BoincUser::lookup_id($team->userid); set_cached_data(TEAM_PAGE_TTL, serialize($team), $cache_args); } if (!$team) { error_page(tra("no such team")); } display_team_page($team, $user); page_tail(true);
function get_job_status() { $s = unserialize(get_cached_data(STATUS_PAGE_TTL, "job_status")); if ($s) { return $s; } $s = new StdClass(); $apps = BoincApp::enum("deprecated=0"); foreach ($apps as $app) { $info = BoincDB::get()->lookup_fields("result", "stdClass", "ceil(avg(elapsed_time)/3600*100)/100 as avg,\n ceil(min(elapsed_time)/3600*100)/100 as min,\n ceil(max(elapsed_time)/3600*100)/100 as max,\n count(distinct userid) as users", "appid = {$app->id}\n AND validate_state=1\n AND received_time > (unix_timestamp()-86400)\n "); $app->info = $info; $app->unsent = BoincResult::count("appid={$app->id} and server_state=2"); $app->in_progress = BoincResult::count("appid={$app->id} and server_state=4"); } $s->apps = $apps; $s->results_ready_to_send = BoincResult::count("server_state=2"); $s->results_in_progress = BoincResult::count("server_state=4"); $s->results_need_file_delete = BoincResult::count("file_delete_state=1"); $s->wus_need_validate = BoincWorkunit::count("need_validate=1"); $s->wus_need_assimilate = BoincWorkunit::count("assimilate_state=1"); $s->wus_need_file_delete = BoincWorkunit::count("file_delete_state=1"); $x = BoincDB::get()->lookup_fields("workunit", "stdClass", "MIN(transition_time) as min", "TRUE"); $gap = (time() - $x->min) / 3600; if ($gap < 0 || $x->min == 0) { $gap = 0; } $s->transitioner_backlog = $gap; $s->users_with_recent_credit = BoincUser::count("expavg_credit>1"); $s->users_with_credit = BoincUser::count("total_credit>1"); $s->users_past_24_hours = BoincUser::count("create_time > (unix_timestamp() - 86400)"); $s->hosts_with_recent_credit = BoincHost::count("expavg_credit>1"); $s->hosts_with_credit = BoincHost::count("total_credit>1"); $s->hosts_past_24_hours = BoincHost::count("create_time > (unix_timestamp() - 86400)"); $s->flops = BoincUser::sum("expavg_credit") / 200; $s->db_revision = null; if (file_exists("../../db_revision")) { $s->db_revision = trim(file_get_contents("../../db_revision")); } $s->cached_time = time(); $e = set_cached_data(STATUS_PAGE_TTL, serialize($s), "job_status"); if ($e) { echo "set_cached_data(): {$e}\n"; } return $s; }