示例#1
0
use GW2Spidy\Dataset\ItemDataset;
require dirname(__FILE__) . '/../autoload.php';
$t = microtime(true);
function mytime()
{
    $r = microtime(true) - $GLOBALS['t'];
    $GLOBALS['t'] = microtime(true);
    return $r;
}
$modnum = null;
$modmod = null;
if (isset($argv[1], $argv[2])) {
    $modnum = $argv[1];
    $modmod = $argv[2];
}
$dm = DatasetManager::getInstance();
$q = ItemQuery::create();
if ($modnum && $modmod) {
    $q->where("data_id % {$modmod} = {$modnum}");
}
var_dump(mytime());
if (!is_null($modnum) && $modnum != 0) {
    do {
        echo "[[ " . mytime() . " ]] [[ TYPE_GEM_TO_GOLD ]] \n";
        $ds = $dm->getGemDataset(GemExchangeDataset::TYPE_GEM_TO_GOLD);
    } while (!$ds->uptodate);
    do {
        echo "[[ " . mytime() . " ]] [[ TYPE_GOLD_TO_GEM ]] \n";
        $ds = $dm->getGemDataset(GemExchangeDataset::TYPE_GOLD_TO_GEM);
    } while (!$ds->uptodate);
}
示例#2
0
<?php

use GW2Spidy\Dataset\DatasetManager;
use GW2Spidy\Util\CacheHandler;
require dirname(__FILE__) . '/../autoload.php';
// memcache is completely purged this way
if (array_intersect(array('-m', '--all'), $argv)) {
    CacheHandler::getInstance("purge")->purge();
    echo "cleared memcache \n";
}
if (array_intersect(array('-d', '--all'), $argv)) {
    DatasetManager::getInstance()->purgeCache();
    echo "cleared dataset \n";
}
if (array_intersect(array('-a', '--all'), $argv) && function_exists('apc_clear_cache') && ($host = getAppConfig("apc_clear_cache_host"))) {
    apc_clear_cache();
    apc_clear_cache('user');
    apc_clear_cache('opcode');
    $hash = md5(uniqid());
    $targetDir = dirname(dirname(__FILE__)) . "/webroot/tmp";
    $target = "{$targetDir}/{$hash}.php";
    if (!is_dir($targetDir)) {
        mkdir($targetDir);
    }
    copy(dirname(__FILE__) . "/clear_apc_cache.php", $target);
    $url = "http://{$host}/tmp/{$hash}.php";
    $result = json_decode(file_get_contents($url), true);
    if (isset($result['success']) && $result['success']) {
        echo "cleared apc \n";
    } else {
        echo "failed to clear apc \n";
示例#3
0
 *  route /gem
 * ----------------------
 */
$app->get("/gem", function () use($app) {
    // workaround for now to set active menu item
    $app->setGemActive();
    $summary = gem_summary();
    return $app['twig']->render('gem.html.twig', (array) $summary);
})->bind('gem');
/**
 * ----------------------
 *  route /gem_chart
 * ----------------------
 */
$app->get("/gem_chart", function () use($app) {
    $chart = array();
    /*---------------------
     *  BUY GEMS WITH GOLD
     *----------------------*/
    $goldToGem = DatasetManager::getInstance()->getGemDataset(GemExchangeDataset::TYPE_GOLD_TO_GEM);
    $chart[] = array('data' => $goldToGem->getNoMvAvgDataForChart(), 'name' => "Gold To Gems Raw Data", 'visible' => true, 'gw2money' => true);
    $chart[] = array('data' => $goldToGem->getDailyMvAvgDataForChart(), 'name' => "Gold To Gems 1 Day Mv Avg", 'visible' => true, 'gw2money' => true);
    /*---------------------
     *  SELL GEMS FOR GOLD
     *----------------------*/
    $gemToGold = DatasetManager::getInstance()->getGemDataset(GemExchangeDataset::TYPE_GEM_TO_GOLD);
    $chart[] = array('data' => $gemToGold->getNoMvAvgDataForChart(), 'name' => "Gems to Gold Raw Data", 'visible' => true, 'gw2money' => true);
    $chart[] = array('data' => $gemToGold->getDailyMvAvgDataForChart(), 'name' => "Gems to Gold 1 Day Mv Avg", 'visible' => true, 'gw2money' => true);
    $content = json_encode($chart);
    return $content;
})->bind('gem_chart');
示例#4
0
})->assert('dataId', '\\d+')->bind('item');
/**
 * ----------------------
 *  route /chart
 * ----------------------
 */
$app->get("/chart/{dataId}", function ($dataId) use($app) {
    $item = ItemQuery::create()->findPK($dataId);
    if (!$item) {
        return $app->abort(404, "Page does not exist.");
    }
    $chart = array();
    $sellListings = DatasetManager::getInstance()->getItemDataset($item, ItemDataset::TYPE_SELL_LISTING);
    $sellListingsVolume = DatasetManager::getInstance()->getItemVolumeDataset($item, ItemVolumeDataset::TYPE_SELL_LISTING);
    $buyListings = DatasetManager::getInstance()->getItemDataset($item, ItemDataset::TYPE_BUY_LISTING);
    $buyListingsVolume = DatasetManager::getInstance()->getItemVolumeDataset($item, ItemVolumeDataset::TYPE_BUY_LISTING);
    /*---------------
     *  MV AVG VOLUME SELL
     *---------------*/
    $chart[] = array('data' => $sellListingsVolume->getDailyMvAvgDataForChart(), 'name' => "Sell Listings Volume 1 Day Mv Avg", 'visible' => true, 'yAxis' => 1, 'type' => 'column');
    /*---------------
     *  MV AVG VOLUME BUY
     *---------------*/
    $chart[] = array('data' => $buyListingsVolume->getDailyMvAvgDataForChart(), 'name' => "Buy Listings Volume 1 Day Mv Avg", 'visible' => true, 'yAxis' => 1, 'type' => 'column');
    /*----------------
     *  SELL LISTINGS
     *----------------*/
    $chart[] = array('data' => $sellListings->getNoMvAvgDataForChart(), 'name' => "Sell Listings Raw Data", 'visible' => true, 'gw2money' => true);
    $chart[] = array('data' => $sellListings->getDailyMvAvgDataForChart(), 'name' => "Sell Listings 1 Day Mv Avg", 'visible' => true, 'gw2money' => true);
    $chart[] = array('data' => $sellListingsVolume->getNoMvAvgDataForChart(), 'name' => "Sell Listings Volume", 'visible' => false, 'yAxis' => 1, 'type' => 'column');
    /*----------------