* get the newest timestamp of the data of a dataset * @param $datasetId * @return int * @throws Exception */
($datasetId)
| 268 | * @throws Exception |
| 269 | */ |
| 270 | public function getLastUpdate($datasetId): int { |
| 271 | $dataset = $this->read((int)$datasetId); |
| 272 | if (is_array($dataset) && ($dataset['storage_mode'] ?? 'legacy') === 'flexible_shared') { |
| 273 | $sql = $this->db->getQueryBuilder(); |
| 274 | $sql->from('analytics_flex_records')->select($sql->func()->max('updated_at'))->where($sql->expr() |
| 275 | ->eq('dataset_id', $sql->createNamedParameter($datasetId))); |
| 276 | $value = $sql->executeQuery()->fetchOne(); |
| 277 | return $value === false || $value === null ? 0 : (int)strtotime((string)$value . ' UTC'); |
| 278 | } |
| 279 | $sql = $this->db->getQueryBuilder(); |
| 280 | $sql->from('analytics_facts')->select($sql->func()->max('timestamp'))->where($sql->expr() |
| 281 | ->eq('dataset', $sql->createNamedParameter($datasetId))); |
| 282 | return (int)$sql->executeQuery()->fetchOne(); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * get the report owner |