Problem with UsageStat and Metrics table


I am using OJS 2.4.8-1 and I am facing some issues with the plugin UsageStats. In the metrics table I have no records of my statistics since 20171105. I’m trying to test this in my development environment but with no luck. Although I move some daily logs to the stage folder, and after the process they get moved to the archived folder, the metrics table doesn’t get updated. I have been starting the process manualy.

I’m not sure wich process to run, so I have tried all three. The logs does’t show any error. Can someone help?

Also, I would like to ask if is there any chance that a may end up publishing any article or issue, running tests on my machine. I see that some schedule tasks have the name like crossreff. I’m afraid it may be possible since the DB is the almost the same as production, with just some changing in email and names.

Hi @Israel87

You should be cautious running the copy of production in a test environment: for example the users could get e-mails, or depending on the Crossref plugin settings, the ‘wrong’ DOI metadata could be registered. I.e. you should be cautious about all plugins that make a connection with other services/service providers. Thus, it is best to disable e-mail function or change all e-mails in your DB table users, as well as to check all enabled plugins and their settings.

Regarding UsageStats: it would be best to first try file by file – to take one file and try to re-process it: move one file to the usageEventLogs/ folder and run the scheduled task. Then see the results. If something goes wrong see also in the scheduledTaskLogs/ folder, the last file starting with “Usagestatisticsfileloadertask-…”.
For running the scheduled task there are several options:
– using the Acron plugin (which you could eventually disable in the test environment, for other scheduled tasks not to be run): when you go to the journal home page or an article view page, the scheduled tasks will be run.
– when you files to be processed are in the usageEventLogs/ folder, running the script: php tools/runScheduledTasks.php lib/pkp/plugins/generic/usageStats/scheduledTasksAutoStage.xml
– when you files to be processed are in the stage/ folder, running the script: php tools/runScheduledTasks.php lib/pkp/plugins/generic/usageStats/scheduledTasks.xml
Before running the scheduled tasks using one of the options here, you should remove the entry UsageStatsLoader form your DB table scheduled_tasks. – The task is meant to be run only once in a day, so if the task already run that day nothing will happen – that’s why you need to remove the entry from the DB table, in order for the task to be able to run again.


1 Like

Thank you @bozana.

It worked now. I was having problems with the scheduled_tasks table as you said, and a miss configuration base_url in

The problem now is the statistic plugin. It is not showing any data for “Article (downloads)” and “Article (abstract)”. Do you have any idea why?

Hi @Israel87

Do you have any data in your DB table metrics in the last year?


Yes, I have data.

I’ve just noted that there is an error when I click these two links. It is right here:

The error message is:

DB Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘dbd_ojs.aset.setting_value’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Stack Trace:

File: /opt/lampp/htdocs/ojs/plugins/generic/statistics/ line 81
Function: DAO->retrieve(“SELECT aset.setting_value, SUM(m.metric) FROM metrics as m INNER…”, Array(4))

File: /opt/lampp/htdocs/ojs/plugins/generic/statistics/ line 198
Function: StatisticsChartsDAO->getMetricsMostPopularByType(“2”, “257”, “2018”, “pt_BR”)

I’ve just tried to add the field “aset.setting_value” to the group by clause and it’s working now. I’m not very used to the group by clause, but i think it is ok, right? I don’t know why it didn’t work in my computer, when it seems it worked in everyone else’s computer. The code now it is like this:

function getMetricsMostPopularByType($journalId, $assoc_type, $year, $primaryLocale){
		$result =& $this->retrieve(
			'SELECT aset.setting_value, SUM(m.metric) FROM metrics as m '. 
			'INNER JOIN article_settings AS aset ON m.submission_id = aset.article_id '.
			'WHERE m.context_id = ? '.
			'AND m.assoc_type = ? '.
			'AND SUBSTR(month,1,4) = ? '.
			'AND aset.setting_name = "title" '.
			'AND aset.locale = ? '.
			'GROUP BY aset.setting_value, m.assoc_id order by SUM(m.metric) DESC LIMIT 20;',
			array((int) $journalId, (int) $assoc_type, $year, $primaryLocale)

Hi @Israel87

Ah, OK. This plugin is not from PKP i.e. does not come with the release.
You can maybe contact the author and explain what problem did you have and how did you solve it, so that he/she knows and eventually repairs it…


Ok. Thank you very much for your help.