MCPcopy Create free account
hub / github.com/Rello/analytics / read

Method read

lib/Db/StorageMapper.php:136–168  ·  view source on GitHub ↗

* read data for dataset * @param int $dataset * @param array $options * @return array */

(int $dataset, $options = '')

Source from the content-addressed store, hash-verified

134 * @return array
135 */
136 public function read(int $dataset, $options = '')
137 {
138 $sql = $this->db->getQueryBuilder();
139 $sql->from(self::TABLE_NAME)
140 ->where($sql->expr()->eq('dataset', $sql->createNamedParameter($dataset)))
141 ->addgroupBy('dataset');
142
143 // loop the available dimensions and check if any is hidden by the drill down selection of the user
144 // if the dimension is not part of the drill down filter, it is not hidden => to be displayed
145 $availableDimensions = array('dimension1', 'dimension2');
146 foreach ($availableDimensions as $dimension) {
147 if (!isset($options['drilldown'][$dimension])) {
148 $sql->addSelect($dimension)
149 ->addGroupBy($dimension)
150 ->addOrderBy($dimension, 'ASC');
151 }
152 }
153
154 // value column deeds to be at the last position in the select. So it needs to be after the dynamic selects
155 $sql->addSelect($sql->func()->sum('value'));
156
157 $this->applyFilterOptions($sql, $options);
158
159 $statement = $sql->executeQuery();
160 $rows = $statement->fetchAll();
161 $statement->closeCursor();
162
163 // reindex result to get rid of the column headers as the frontend works incremental
164 foreach ($rows as &$row) {
165 $row = array_values($row);
166 }
167 return $rows;
168 }
169
170 /**
171 * delete data

Callers

nothing calls this directly

Calls 1

applyFilterOptionsMethod · 0.95

Tested by

no test coverage detected