| @@ 49-66 (lines=18) @@ | ||
| 46 | * |
|
| 47 | * @return array |
|
| 48 | */ |
|
| 49 | public function readStatistics($post) |
|
| 50 | { |
|
| 51 | $redisKey = "{$this->getCacheNamespace()}:{$this->getType()}"; |
|
| 52 | $redisKey = $this->appendRedisKey($post, $redisKey); |
|
| 53 | $post = $this->processPostVars($post); |
|
| 54 | ||
| 55 | if ($this->checkRedis($redisKey)) { |
|
| 56 | return $this->getFromRedis($redisKey); |
|
| 57 | } |
|
| 58 | ||
| 59 | $queryObject = new QueryObject; |
|
| 60 | $queryObject = $this->setupQueryObject($queryObject, $post); |
|
| 61 | ||
| 62 | return $this->cacheAndReturn( |
|
| 63 | $this->repository->read($queryObject), |
|
| 64 | $redisKey |
|
| 65 | ); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Build a redis key based off inputs provided by the POST request |
|
| @@ 56-78 (lines=23) @@ | ||
| 53 | * |
|
| 54 | * @return array |
|
| 55 | */ |
|
| 56 | public function readTotals() |
|
| 57 | { |
|
| 58 | $redisKey = "{$this->getCacheNamespace()}:{$this->getType()}:Totals"; |
|
| 59 | $post = $this->processPost(); |
|
| 60 | ||
| 61 | $redisKey = $this->appendRedisKey($post, $redisKey); |
|
| 62 | ||
| 63 | if ($this->checkRedis($redisKey)) { |
|
| 64 | return $this->getFromRedis($redisKey); |
|
| 65 | } |
|
| 66 | ||
| 67 | $queryObject = new QueryObject; |
|
| 68 | $queryObject = $this->setupQueryObject($queryObject, $post); |
|
| 69 | ||
| 70 | $queryObject->addSelect('COUNT(ResultID) AS COUNT'); |
|
| 71 | ||
| 72 | $this->setCacheExpireTime(900); // 15 mins |
|
| 73 | ||
| 74 | return $this->cacheAndReturn( |
|
| 75 | $this->repository->read($queryObject), |
|
| 76 | $redisKey |
|
| 77 | ); |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * Retrieves all zone totals and caches as required |
|