My problem or how works archiveDay


#1

Good morning.

I think I’m not using in the right way the hook archiveDay, but I’ve been searching for issues similar to mine, but didn’t find anything, so I’ll post my problem.

In my plugin on plugin_name.php file, I create the hook of archiveDay, and make a query which data I want archiveDay to store.

I try to store the data this way,

$query = “Select …”; //The select is ok,

$res = $archiveProcessing->db->query($query, array( $archiveProcessing->getStartDatetimeUTC(), $archiveProcessing->getEndDatetimeUTC()));

$recordName = ‘My_data’;
$columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS;
$maximumRowsInDataTable = Zend_Registry::get(‘config’)->General->datatable_archiving_maximum_rows_standard;

$archiveProcessing->insertBlobRecord($recordName, $res);

When I run cron the data doesn’t stores and doesn’t throw error message or anything that can point me in the right direction.
Maybe I’m doing this wrong, and there is another way.

Any help will be really appreciated.

And sorry about my english.

Thanks!


(JulienM) #2

When you say “I create the hook of archiveDay”, could you be more precise and copy paste the code you used to create the hook ?


#3

Julien! I couldn’t check this until now.
Sorry for answering late, I appreciate your interest!

The code I use for the Hook :


public function getListHooksRegistered()
	{
		return array( 
			'Menu.add' => 'addMenus',
			'WidgetsList.add' => 'addWidgets',
			'ArchiveProcessing_Day.compute' => 'archiveDay',
			'ArchiveProcessing_Period.compute' => 'archivePeriod',
		);
	}

And for the function:



public function archiveDay($notification)
{
     $archiveProcessing = $notification->getNotificationObject();

     $query = "....";    

     $res = Piwik_Query($query); //a simple query and it works I tested it

     while( $row = $res->fetch() ) 
     {
          .....
     }

     //the while generates a label => value vector, and it's ok ( Checked that )

     //Maybe here is where I'm lost or using some function wrong
     
     // serialize the vector, and save it to the DB
     $dataTable->addRowsFromArrayWithIndexLabel($vec);
     $s = Piwik_ArchiveProcessing_Day::getDataTableSerialized($vec);
     $archiveProcessing->insertBlobRecord('Ranking_Noticias', $vec);
     destroy($dataTable);
}


Maybe I’m doing something wrong.

I’ll appreciate any help.

Thank you!


#4

Did you remove archive entries for the date you are testing?
If there are already entries in the “archive_blob_YYYYMM” table, no event is thrown and none of the hook’s registered plugins are called.
Check data for the day of interest, too: it the count of entries for the day is zero, the “ArchiveDay::compute” will return and no event will be thrown.

Hope this hepl.