Exemplo n.º 1
0
        $iskEff = $iskDestroyed / ($iskDestroyed + $iskLost);
        $pointsDestroyed = getValue($row, 'recentPointsDestroyed', $size);
        $pointsDestroyedRank = getValue($row, 'recentPointsDestroyedRank', $size);
        $pointsLost = getValue($row, 'recentPointsLost', $size);
        $pointsLostRank = getValue($row, 'recentPointsLostRank', $size);
        $pointsEff = $pointsDestroyed / ($pointsDestroyed + $pointsLost);
        $avg = ceil(($shipsDestroyedRank + $iskDestroyedRank + $pointsDestroyedRank) / 3);
        $adjuster = (1 + $shipsEff + $iskEff + $pointsEff) / 4;
        $score = ceil($avg / $adjuster);
        $mdb->getCollection('statistics')->update($row, ['$set' => ['recentOverallScore' => (int) $score]]);
    }
    $currentRank = 0;
    $result = $mdb->find('statistics', ['type' => $type], ['recentOverallScore' => 1], null, ['months' => 0, 'groups' => 0]);
    foreach ($result as $row) {
        if (@$row['recentOverallScore'] == null) {
            $mdb->getCollection('statistics')->update($row, ['$unset' => ['recentOverallRank' => 1]]);
        } else {
            ++$currentRank;
            $mdb->getCollection('statistics')->update($row, ['$set' => ['recentOverallRank' => $currentRank]]);
            $mdb->insertUpdate('ranksProgress', ['type' => $type, 'id' => $row['id'], 'date' => $date], ['recentOverallRank' => $currentRank]);
        }
    }
}
function getValue($array, $field, $default)
{
    $value = @$array[$field];
    if ((int) $value != 0) {
        return $value;
    }
    return $default;
}
Exemplo n.º 2
0
    $update = [];
    $update['lastApiUpdate'] = $mdb->now();
    $update['corpCount'] = (int) $alliCrest['corporationsCount'];
    $update['executorCorpID'] = (int) @$alliCrest['executorCorporation']['id'];
    addCorp($update['executorCorpID']);
    $memberCount = 0;
    $update['deleted'] = $alliCrest['deleted'];
    $mdb->set('information', ['type' => 'corporationID', 'allianceID' => $id], ['allianceID' => 0]);
    if ($alliCrest['corporations']) {
        foreach ($alliCrest['corporations'] as $corp) {
            $corpID = (int) $corp['id'];
            addCorp($corpID);
            $infoCorp = $mdb->findDoc('information', ['type' => 'corporationID', 'id' => $corpID]);
            $memberCount += (int) @$infoCorp['memberCount'];
            $mdb->set('information', ['type' => 'corporationID', 'id' => $corpID], ['allianceID' => $id]);
        }
    }
    $update['memberCount'] = $memberCount;
    $update['ticker'] = $alliCrest['shortName'];
    $update['name'] = $alliCrest['name'];
    $mdb->insertUpdate('information', ['type' => 'allianceID', 'id' => $id], $update);
}
function addCorp($id)
{
    global $mdb;
    $query = ['type' => 'corporationID', 'id' => (int) $id];
    $infoCorp = $mdb->findDoc('information', $query);
    if ($infoCorp == null) {
        $mdb->insertUpdate('information', $query);
    }
}