diff options
author | Peter Zhang <peter@innocraft.com> | 2022-03-07 16:49:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-07 16:49:49 +0300 |
commit | 8188140d9daf90b2aec1bbd6ff76b2218c288ad0 (patch) | |
tree | db985a017982221f5e5daf5671dea5b2691e757f /core | |
parent | d25af6d0a0db467ffd4d4e58540906e554483879 (diff) |
[UI] add report date on overview reports and fix date display (#18838)
* update date on overview
update date on overview
* built vue files
* Update plugins/CoreHome/templates/_dataTable.twig
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* update largest key
update largest key
* update checks
update checks
* Update Map.php
reset map class
* Update Visualization.php
update a condition
* Update Visualization.php
update some condition
* Update Visualization.php
convert meta data to local var
* ini $metadata
ini $metadata
* Update Visualization.php
update error
* Update core/Plugin/Visualization.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/Plugin/Visualization.php | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index dd99f5a5e8..b2ff753f31 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -157,7 +157,6 @@ class Visualization extends ViewDataTable private $templateVars = array(); private $reportLastUpdatedMessage = null; - private $metadata = null; protected $metricsFormatter = null; /** @@ -458,14 +457,35 @@ class Visualization extends ViewDataTable } // deal w/ table metadata + $metadata = null; if ($this->dataTable instanceof DataTable) { - $this->metadata = $this->dataTable->getAllTableMetadata(); - - if (isset($this->metadata[DataTable::ARCHIVED_DATE_METADATA_NAME])) { - $this->reportLastUpdatedMessage = $this->makePrettyArchivedOnText(); + $metadata = $this->dataTable->getAllTableMetadata(); + } else { + // if the dataTable is Map + if ($this->dataTable instanceof DataTable\Map) { + // load all the data + $dataTable = $this->dataTable->getDataTables(); + // find the latest key + foreach ($dataTable as $item) { + $itemMetaData = $item->getAllTableMetadata(); + // initial metadata and update metadata if current is more recent + if (!empty($itemMetaData[DataTable::ARCHIVED_DATE_METADATA_NAME]) + && ( + empty($metadata[DataTable::ARCHIVED_DATE_METADATA_NAME]) + || strtotime($itemMetaData[DataTable::ARCHIVED_DATE_METADATA_NAME]) > strtotime($metadata[DataTable::ARCHIVED_DATE_METADATA_NAME]) + ) + ) { + $metadata = $itemMetaData; + } + } } } + // if metadata set display report date + if (!empty($metadata[DataTable::ARCHIVED_DATE_METADATA_NAME])) { + $this->reportLastUpdatedMessage = $this->makePrettyArchivedOnText($metadata[DataTable::ARCHIVED_DATE_METADATA_NAME]); + } + $pivotBy = Common::getRequestVar('pivotBy', false) ?: $this->requestConfig->pivotBy; if (empty($pivotBy) && $this->dataTable instanceof DataTable @@ -558,14 +578,16 @@ class Visualization extends ViewDataTable } } + /** * Returns prettified and translated text that describes when a report was last updated. * + * @param $dateText * @return string + * @throws \Exception */ - private function makePrettyArchivedOnText() + private function makePrettyArchivedOnText($dateText) { - $dateText = $this->metadata[DataTable::ARCHIVED_DATE_METADATA_NAME]; $date = Date::factory($dateText); $today = mktime(0, 0, 0); $metricsFormatter = new HtmlFormatter(); |