public function process() { $date = $this->ga->getDates(); $beforeDate = $this->ga->getDates('Y-m-d', true); $url = $this->ga->buildUrl($date['begin'], $date['end'], array('ga:date'), $this->metrics); $cacheKey = md5($this->ga->cacheKey); $fromCache = $this->modx->cacheManager->get($cacheKey); if (!empty($fromCache)) { return $this->success('Fetched data from cache', $fromCache); } if (!$this->ga->loadOAuth()) { return $this->failure('Could not load the OAuth file.'); } if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->addSerie(); // Get the second area for comparion $url = $this->ga->buildUrl($beforeDate['begin'], $beforeDate['end'], array('ga:date'), $this->metrics); if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->addSerie(true); $this->modx->cacheManager->set($cacheKey, $this->series, $this->ga->getOption('cache_timeout')); return $this->success('Fetched data from Google', $this->series); }
public function process() { $date = $this->ga->getDates(); $url = $this->ga->buildUrl($date['begin'], $date['end'], array('ga:date'), $this->metrics, array('-ga:visits')); $cacheKey = $this->ga->cacheKey; $fromCache = $this->modx->cacheManager->get($cacheKey); if (!empty($fromCache)) { return $this->success('Fetched data from cache', $fromCache, true); } if (!$this->ga->loadOAuth()) { return $this->failure('Could not load the OAuth file.'); } if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->formatData(); $date = $this->ga->getDates('Y-m-d', true); $url = $this->ga->buildUrl($date['begin'], $date['end'], null, $this->metrics, array('-ga:visits')); if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->compareData(); $this->modx->cacheManager->set($cacheKey, $this->output, $this->ga->getOption('cache_timeout')); return $this->success('Fetched data from Google', $this->output); }
public function process() { $date = $this->ga->getDates(); $url = $this->ga->buildUrl($date['begin'], $date['end'], $this->dimensions, $this->metrics, $this->sort); $cacheKey = $this->ga->cacheKey; $fromCache = $this->modx->cacheManager->get($cacheKey); if (!empty($fromCache)) { return $this->success('Fetched data from cache', $fromCache, true); } if (!$this->ga->loadOAuth()) { return $this->failure('Could not load the OAuth file.'); } if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->addSerie(); $this->modx->cacheManager->set($cacheKey, $this->series, $this->ga->getOption('cache_timeout')); return $this->success('Fetched data from Google', $this->series); }
public function process() { $date = $this->ga->getDates(); $url = $this->ga->buildUrl($date['begin'], $date['end'], $this->dimension, $this->metrics, array('-ga:visits'), $this->filters, $this->limit); $cacheKey = $this->ga->cacheKey; $fromCache = $this->modx->cacheManager->get($cacheKey); if (!empty($fromCache)) { return $this->success('Fetched data from cache', $fromCache, true); } if (!$this->ga->loadOAuth()) { return $this->failure('Could not load the OAuth file.'); } if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->visits = $this->ga->getTotalVisits($date['begin'], $date['end']); $response = $this->iterate(); $this->modx->cacheManager->set($cacheKey, $response, $this->ga->getOption('cache_timeout')); return $this->success('Fetched data from Google', $response); }