function decay($is_user) { $now = time(); if ($is_user) { $cs = BoincCreditUser::enum(""); } else { $cs = BoincCreditTeam::enum(""); } foreach ($cs as $c) { update_average($now, 0, 0, $c->expavg, $c->expavg_time); if ($is_user) { $c->update("expavg={$c->expavg}, expavg_time={$c->expavg_time} where userid={$c->userid} and appid={$c->appid}"); } else { $c->update("expavg={$c->expavg}, expavg_time={$c->expavg_time} where teamid={$c->teamid} and appid={$c->appid}"); } } }
function export_item($item, $is_user, $f) { global $sub_projects; fprintf($f, $is_user ? "<user>\n" : "<team>\n"); fprintf($f, " <id>{$item->id}</id>\n"); $crs = $is_user ? BoincCreditUser::enum("userid={$item->id}") : BoincCreditTeam::enum("teamid={$item->id}"); foreach ($sub_projects as $sub_project) { $total = 0; $average = 0; $njobs = 0; foreach ($crs as $cr) { if (in_array($cr->appid, $sub_project["appids"])) { $total += $cr->total; $average += $cr->expavg; $njobs += $cr->njobs; } } if ($total) { fprintf($f, " <subproject name=\"" . $sub_project["name"] . "\">\n" . " <workunits>{$njobs}</workunits>\n" . " <credit>{$total}</credit>\n" . " <expavg_credit>{$average}</expavg_credit>\n" . " </subproject>\n"); } } fprintf($f, $is_user ? "</user>\n" : "</team>\n"); }
function show_list($is_team, $appid, $is_total) { $x = $is_team ? "teams" : "participants"; page_head("Top {$x} by application"); $apps = BoincApp::enum("deprecated=0"); if (!$appid) { $appid = $apps[0]->id; } start_table(); show_header($is_team, $apps, $appid, $is_total); $x = $is_total ? "total" : "expavg"; if ($is_team) { $items = BoincCreditTeam::enum("appid={$appid} order by {$x} desc"); } else { $items = BoincCreditUser::enum("appid={$appid} order by {$x} desc"); } $i = 0; foreach ($items as $item) { show_row($item, $apps, $is_team, $i); $i++; } end_table(); page_tail(); }