Example #1
0
 /**
  * update the current dataset with new values from the database
  *  if posible only with values since our lastUpdated moment
  */
 public function updateDataset()
 {
     if ($this->updated) {
         return;
     }
     $limit = 20000;
     $end = null;
     $start = $this->lastUpdated;
     $con = \Propel::getConnection();
     $table = $this->type == self::TYPE_SELL_LISTING ? 'sell_listing' : 'buy_listing';
     $and = "";
     // only retrieve new ticks since last update
     if ($start) {
         $and = " AND listing_datetime > '{$start->format('Y-m-d H:i:s')}'";
     }
     $stmt = $con->prepare("\n                SELECT\n                listing_datetime AS listingDatetime,\n                MIN(unit_price) AS min_unit_price\n                FROM {$table}\n                WHERE item_id = {$this->itemId}\n                {$and}\n                GROUP BY listing_datetime\n                ORDER BY listing_datetime ASC\n                LIMIT {$limit}");
     $stmt->execute();
     $listings = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     foreach ($listings as $listing) {
         $date = new DateTime("{$listing['listingDatetime']}");
         $rate = intval($listing['min_unit_price']);
         $end = $date;
         $this->processTick($date, $rate);
     }
     if (!($this->uptodate = count($listings) != $limit)) {
         $app = Application::getInstance();
         $app['no_cache'] = true;
     }
     // update for next time
     $this->updated = true;
     if ($end) {
         $this->lastUpdated = $end;
     }
 }
 /**
  * update the current dataset with new values from the database
  *  if posible only with values since our lastUpdated moment
  */
 public function updateDataset()
 {
     if ($this->updated) {
         return;
     }
     $limit = 20000;
     $end = null;
     $start = $this->lastUpdated;
     $con = \Propel::getConnection();
     $table = $this->type == self::TYPE_GEM_TO_GOLD ? 'gem_to_gold_rate' : 'gold_to_gem_rate';
     $where = "";
     // only retrieve new ticks since last update
     if ($start) {
         $where = " WHERE rate_datetime > '{$start->format('Y-m-d H:i:s')}'";
     }
     $stmt = $con->prepare("\n                SELECT\n                rate_datetime AS rateDatetime,\n                rate\n                FROM {$table}\n                {$where}\n                ORDER BY rate_datetime ASC\n                LIMIT {$limit}");
     $stmt->execute();
     $rates = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     foreach ($rates as $rateEntry) {
         $date = new DateTime("{$rateEntry['rateDatetime']}");
         $rate = intval($rateEntry['rate']);
         $end = $date;
         $this->processTick($date, $rate);
     }
     if (!($this->uptodate = count($rates) != $limit)) {
         $app = Application::getInstance();
         $app['no_cache'] = true;
     }
     // update for next time
     $this->updated = true;
     if ($end) {
         $this->lastUpdated = $end;
     }
 }
Example #3
0
 /**
  *
  * @return CacheHandler
  */
 public static function getInstance($key)
 {
     if (!isset(static::$instances[$key])) {
         static::$instances[$key] = new static($key);
         if (Application::getInstance()->isMemcachedEnabled()) {
             static::$instances[$key]->connect('localhost');
         } else {
             static::$instances[$key]->setEnabled(false);
         }
     }
     return static::$instances[$key];
 }
Example #4
0
/**
 * using Silex micro framework
 *  this file contains all routing and the 'controllers' using lambda functions
 */
use GW2Spidy\Application;
use GW2Spidy\Security\CustomSecurityServiceProvider;
use GW2Spidy\Twig\VersionedAssetsRoutingExtension;
use GW2Spidy\Twig\ItemListRoutingExtension;
use GW2Spidy\Twig\GW2MoneyExtension;
use GW2Spidy\Twig\GenericHelpersExtension;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
require dirname(__FILE__) . '/../autoload.php';
Request::trustProxyData();
// initiate the application, check config to enable debug / sql logging when needed
$app = Application::getInstance();
$app['no_cache'] = false;
// register config provider
$app->register(new Igorw\Silex\ConfigServiceProvider(getAppConfig()));
// setup dev mode related stuff based on config
$app['sql_logging'] && $app->enableSQLLogging();
// register our custom security provider
$app->register(new CustomSecurityServiceProvider());
// register providers
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => dirname(__FILE__) . '/../templates', 'twig.options' => array('cache' => dirname(__FILE__) . '/../tmp/twig-cache')));
// register custom twig extensions
$app['twig']->addExtension(new GenericHelpersExtension());
$app['twig']->addExtension(new VersionedAssetsRoutingExtension($app['url_generator']));
$app['twig']->addExtension(new GW2MoneyExtension());
 protected function getVersionString()
 {
     return Application::getInstance()->getVersionString();
 }