diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-03-04 00:24:46 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-03-04 00:24:46 +0400 |
commit | cbe88c1ab471c717fbee06eebe556cc97c5da6e5 (patch) | |
tree | df028b9b6b39b17961d97312749309fcc451b029 /plugins/Insights | |
parent | c2fbcfeecdd3ed99d2139361d2855c0b70624e1b (diff) |
refs #57 destroy all tables but the insights tables
Diffstat (limited to 'plugins/Insights')
-rw-r--r-- | plugins/Insights/API.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/Insights/API.php b/plugins/Insights/API.php index 4234bdd4dc..f26bec619c 100644 --- a/plugins/Insights/API.php +++ b/plugins/Insights/API.php @@ -43,14 +43,25 @@ class API extends \Piwik\Plugin\API 'Referrers_getCampaigns', 'Referrers_getAll' ); - // post event to add other reports? + $reportTableIds = array(); + $dataTableManager = DataTable\Manager::getInstance(); + $tables = array(); foreach ($reports as $report) { - $tableId = DataTable\Manager::getInstance()->getMostRecentTableId(); - $tables[] = $this->getInsightOverview($idSite, $period, $date, $report); - DataTable\Manager::getInstance()->deleteAll($tableId); + $firstTableId = $dataTableManager->getMostRecentTableId(); + $table = $this->getInsightOverview($idSite, $period, $date, $report); + $reportTableIds[] = $table->getId(); + $lastTableId = $dataTableManager->getMostRecentTableId(); + + for ($index = $firstTableId; $index < $lastTableId; $index++) { + if (!in_array($index, $reportTableIds)) { + DataTable\Manager::getInstance()->deleteTable($index); + } + } + + $tables[] = $table; } $map = new DataTable\Map(); |