@@ -140,45 +140,45 @@ |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Loads the recently updated statistics data from the database. |
|
| 145 | - * |
|
| 146 | - * Updated within a timeframe, submit a pull request for a different behavior. |
|
| 147 | - * |
|
| 148 | - * @return array An array containing the response data |
|
| 149 | - */ |
|
| 150 | - public function getTimeframeUpdatedItems(int $timeframe = 0, string $showColumn = ''): array |
|
| 151 | - { |
|
| 152 | - $return = []; |
|
| 153 | - $columns = self::ALLOWED_SOURCES; |
|
| 154 | - if ($showColumn !== '') { |
|
| 155 | - // The column should exist in the table and be part of the API |
|
| 156 | - if (!\in_array($showColumn, self::ALLOWED_SOURCES)) { |
|
| 157 | - throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - $columns = [$showColumn]; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - foreach ($columns as $column) { |
|
| 164 | - if (\in_array($column, ['cms_php_version', 'db_type_version'])) { |
|
| 165 | - throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
| 166 | - } |
|
| 167 | - $return[$column] = $this->db->setQuery( |
|
| 168 | - $this->db->getQuery(true) |
|
| 169 | - ->select($column) |
|
| 170 | - ->select('COUNT(' . $column . ') AS count') |
|
| 171 | - ->from('(SELECT * FROM ' . $this->db->quoteName('#__jstats') . ' WHERE modified > DATE_SUB(NOW(), INTERVAL ' . $this->db->quote($timeframe) .' DAY)) AS tmptable') |
|
| 172 | - ->group($column) |
|
| 173 | - )->loadAssocList(); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ($showColumn !== '') { |
|
| 177 | - return $return[$showColumn]; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return $return; |
|
| 181 | - } |
|
| 143 | + /** |
|
| 144 | + * Loads the recently updated statistics data from the database. |
|
| 145 | + * |
|
| 146 | + * Updated within a timeframe, submit a pull request for a different behavior. |
|
| 147 | + * |
|
| 148 | + * @return array An array containing the response data |
|
| 149 | + */ |
|
| 150 | + public function getTimeframeUpdatedItems(int $timeframe = 0, string $showColumn = ''): array |
|
| 151 | + { |
|
| 152 | + $return = []; |
|
| 153 | + $columns = self::ALLOWED_SOURCES; |
|
| 154 | + if ($showColumn !== '') { |
|
| 155 | + // The column should exist in the table and be part of the API |
|
| 156 | + if (!\in_array($showColumn, self::ALLOWED_SOURCES)) { |
|
| 157 | + throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + $columns = [$showColumn]; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + foreach ($columns as $column) { |
|
| 164 | + if (\in_array($column, ['cms_php_version', 'db_type_version'])) { |
|
| 165 | + throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
| 166 | + } |
|
| 167 | + $return[$column] = $this->db->setQuery( |
|
| 168 | + $this->db->getQuery(true) |
|
| 169 | + ->select($column) |
|
| 170 | + ->select('COUNT(' . $column . ') AS count') |
|
| 171 | + ->from('(SELECT * FROM ' . $this->db->quoteName('#__jstats') . ' WHERE modified > DATE_SUB(NOW(), INTERVAL ' . $this->db->quote($timeframe) .' DAY)) AS tmptable') |
|
| 172 | + ->group($column) |
|
| 173 | + )->loadAssocList(); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ($showColumn !== '') { |
|
| 177 | + return $return[$showColumn]; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return $return; |
|
| 181 | + } |
|
| 182 | 182 | /** |
| 183 | 183 | * Saves the given data. |
| 184 | 184 | * |