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}");
        }
    }
}
Ejemplo n.º 2
0
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");
}
Ejemplo n.º 3
0
function assign_sub_badge($is_user, $item, $levels, $badges, $where_clause)
{
    if ($is_user) {
        $sub_total = BoincCreditUser::sum('total', "where userid=" . $item->id . " and ({$where_clause})");
    } else {
        $sub_total = BoincCreditTeam::sum('total', "where teamid=" . $item->id . " and ({$where_clause})");
    }
    // count from highest to lowest level, so the user get's assigned the
    // highest possible level and the lower levels get removed
    //
    for ($i = count($levels) - 1; $i >= 0; $i--) {
        if ($sub_total >= $levels[$i]) {
            assign_badge($is_user, $item, $badges[$i]);
            unassign_badges($is_user, $item, $badges, $i);
            return;
        }
    }
    // no level could be assigned so remove them all
    //
    unassign_badges($is_user, $item, $badges, -1);
}
Ejemplo n.º 4
0
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();
}