Data Archiving, Sorting and Pagination


#1

I added a new table to the piwik database some weeks ago and wrote an plugin to display the data.

I added an method to my API.php named getRequest:


$date = Piwik_Date::factory($date);
$period = Piwik_Period::factory($period, $date);
$dateStart = $period->getDateStart()->toString('Y-m-d H:i:s');
$dateEnd = $period->getDateEnd()->toString('Y-m-d'). " 23:59:59" ); 

$sqlQuery = "SELECT * FROM piwik_log_methods WHERE called_at BETWEEN timestamp(?) AND timestamp(?) AND idSite = ?";
$sqlBind = array( $idSite, $dateStart, $dateEnd );

$rows = Piwik_FetchAll($sqlQuery, $sqlBind);

$dataTable = new Piwik_DataTable(); 		$dataTable->addRowsFromSimpleArray($array);
return $dataTable;

1.) How could I add this data to the piwik archive?
2.) Do I need to calculate the period? How I could handle this in the archiving process?

In my Controller added an method named getRequests:


$view = Piwik_ViewDataTable::factory('table');
$view->init( $this->pluginName, __FUNCTION__, 'MyPlugin.getRequests' );
$view->setSortedColumn('called_at', 'desc');
return $this->renderView($view, true);

This calls the getRequest method in the Piwik_MyPlugin_API class, which returns the Piwik_DataTable I mentioned previously. Finally, I see the datatable in my Piwik Admin UI.

I want to sort by another column and click on its column head, piwik shows me an loading bar endlessly. The same endless loading bar appears when I click on the “next” link to show the next 10 rows of data.

1.) Why Piwik is behaving like this?
2.) Is there something I do the wrong way?


(Matthieu Aubry) #2

when there is the loading… bar forever, look with firebug at your request to see which error it is throwing?


#3

I will try that tomorrow, when I am back at the office.
But there are still some unanswered questions:

1.) How could I add my data to the piwik archive?
2.) Do I need to calculate the period? How I could handle this in the archiving process?


#4

So. Here it is:


$(elem).offset() is null
{var elemTop=$(elem).offset().top;if(e...dow).scrollTop()+$(window).height()) 

The request:


action = getRequests
date	= 2011-03-09
enable_sort = 1
filter_limit = 10
filter_offset = 10
filter_only_display_idgoa...	 = -1
filter_sort_column = calltime
filter_sort_order = asc
idSite = 1
module = MyPlugin
period = week
totalRows =13
viewDataTable = table


#5

push

I am still waiting for an answer!


#6

push again.

Still waiting.


(Peterbo) #7

Please have a look at the other plugins that are archiving data; For Archiving custom data, have a look at SteveG’s demographic Plugin: New Plugin: Demography reporting · Issue #1436 · matomo-org/matomo · GitHub


#8

Thanks for your answer,

but this is the third time I need to write this: I save my data in an OWN table in the database and NOT into the log_visit table like the Community Plugin by Steve G.

And this is not the first time I am reading the “look into the code of $insertpluginname” advice. I’ve read a lot of code. The ArchiveProcessing classes and the Piwik_DataTable class, but I still don’t understand anything. Every project I know has an proper documentation, where I can lookup things. But the documentation of Piwik is more like an big load of bricks and an chainsaw.

So I ask my question again:
How could I add data from an separate database table to the Archive?

If I am just to stupid to understand the piwik code and the so called documentation, then please tell me. sigh


(Matthieu Aubry) #9

Sorry, if you don’t understand the code, then we can’t really help since, as you point out, there is not really a doc at the moment… no you’re not stupid, it’s definitely non trivial code. Hopefully we can write more doc in the future, but there is always so much we can do.