@eramirez wrote:
I'm developing a new plugin, my Archiver.php has these functions:
class Archiver extends \Piwik\Plugin\Archiver { const READINGS_RECORD_NAME = "Readings_archive_record"; const READINGS_FIELD = "page_id"; public function aggregateDayReport(){ $data = array( array("label" => "Primer artículo", "visits" => "1", "readings" => "0"), array("label" => "Segundo artículo", "visits" => "2", "readings" => "0"), array("label" => "Tercer artículo", "visits" => "3", "readings" => "1") ); $dataTable = new DataTable(); $dataTable->addRowsFromSimpleArray($data); $serializedDataTable = $dataTable->getSerialized(); $archiveProcessor = $this->getProcessor(); $archiveProcessor->insertBlobRecord(self::READINGS_RECORD_NAME, $serializedDataTable); } public function aggregateMultipleReports() { $archiveProcessor = $this->getProcessor(); $archiveProcessor->aggregateDataTableRecords(self::READINGS_RECORD_NAME); } }
The first function is supposed to create a daily record using the $data variable. And the second function should sum these records created in the previous function and create new records for different periods (week, month, year, date range).
Today is 2017-04-07 and when I call the API method:
public function getLecturas($segment = false) { $archive = Archive::build($idSite, $period, $date, $segment); $dataTable = $archive->getDataTable(Archiver::READINGS_RECORD_NAME); return $dataTable; }
...using date=2017-04-07&period=day, it all works fine, I get the expected result (the $data array from the aggregateDayReport function), but when I call the API method with these dates: 2017-04-08 and 2017-04-09, it returns the same $data array. This does not happen when I consult other dates, just the two next days. And in my piwik_archive_blob_2017_04 table I see that these registers are created:
- 902 / Readings_archive_record / 1 / 2017-04-07 / 2017-04-07 / 1 / 2017-04-07 10:25:00 / [BLOB - 137 B]
- 901 / Readings_archive_record / 1 / 2017-04-09 / 2017-04-09 / 1 / 2017-04-07 10:22:42 / [BLOB - 137 B]
- 900 / Readings_archive_record / 1 / 2017-04-08 / 2017-04-08 / 1 / 2017-04-07 10:22:42 / [BLOB - 137 B]
- 899 / Readings_archive_record / 1 / 2017-04-03 / 2017-04-09 / 2 / 2017-04-07 10:22:45 / [BLOB - 135 B]
- 898 / Readings_archive_record / 1 / 2017-04-07 / 2017-04-07 / 1 / 2017-04-07 10:21:23 / [BLOB - 137 B]
Why are being recorded registers with future dates? I understand that when I select period=week/month/year/dateRange this happens, but daily records with future dates? Please, help me. My reports are showing wrong data because of this.
Posts: 1
Participants: 1