OJS Plugin: Statistic Charts (2.4.3 to 2.4.8-1)

Hi @OSU,

It seems that the problem is in geolocation statistics, because the fields (country_id, region, city) are not informed.

For more information about PKP Statistics Framework, can you visit this site: https://pkp.sfu.ca/wiki/index.php?title=PKP_Statistics_Framework
(view 5.1.1 Geolocation database)

I think that the problem is here… but i’m not a expert. Maybe someone of the PKP staff, can help us best in this topic.

franms, thanks for reply!

Yes, i have done some steps yesterday:

download and decompress file GeoLiteCity.dat to the directory
plugins/generic/usageStats/

but what to do next ? What should I do then ?
no results yet…

Do I need to create a separate topic to solve this problem?

1 Like

After adding the GeoLiteCity.dat file, you will need to re-process your old logs to generate the location-based metrics. See:
https://pkp.sfu.ca/wiki/index.php?title=PKP_Statistics_Framework#Reprocessing_log_files

1 Like

yes, thanks for link.
I have read, but there is no explanation…
i have never done it before.
could you give more extended instruction, please! maybe link…
where can i do this old log re-process? in phpmyadmin?

Did you read the “Advanced” subsection of the “Processing Log Files” section, just above what I linked?
https://pkp.sfu.ca/wiki/index.php?title=PKP_Statistics_Framework#Advanced

You can find a general description of the expected process here:

Reprocessing the existing logs should be as simple as moving them from the “archive” folder to the “stage” folder.

1 Like

Thank you @franms for the plugin!
Although it’s working as expected with 2.4.8-1, I’m getting some warnings in the error log. For example:

Message: WARNING: Missing argument 4 for GenericPlugin::manage(), called in /[path]/ojs/plugins/generic/statistics/StatisticsPlugin.inc.php on line 106 and defined\n In file: /[path]/ojs/lib/pkp/classes/plugins/GenericPlugin.inc.php\n At line: 58\n

The following patch seems to solve the issue for me:

— a/plugins/generic/statistics/StatisticsPlugin.inc.php 2016-10-11 11:02:06.
+++ b/plugins/generic/statistics/StatisticsPlugin.inc.php 2016-10-11 11:03:26
@@ -100,10 +100,12 @@
* @param $verb string
* @param $args array
* @param $message string Location for the plugin to put a result msg

  •     * @param $messageParams array Parameters for the message key
       * @return boolean
       */
    
  •   function manage($verb, $args, &$message) {
    
  •           if (!parent::manage($verb, $args, $message)) return false;
    
  •   function manage($verb, $args, &$message, &$messageParams) {
    
  •           if (!parent::manage($verb, $args, $message, $messageParams)) return false;
    
  •           switch ($verb) {
                      case 'statistics':
                              Request::redirect(null, 'statistics');
    

And one question: what code changes would be required to restrict access to this plugin to certain users? (so that ie only journal managers would be able to see the ‘Statistics’ link and also see the actual statistics)

Thanks in advance,
Theodoros

Thank you for this plugin. It save me time. Everything works fine in our site.

Thank you @franms I have implemented your plugin in our journal: http://jtsiskom.undip.ac.id/index.php/jtsiskom/statistics.
Everything is going well, except for country chart. It shows small number of country download or abstract view.
I download the plugin from git.
How to fix this? Thank you.

I am using OJS 2.4.8-2, how to install Statistics Chart plugin on OJS 2.4.8-2? Although it only supports up to OJS 2.4.8-1, but there is definitely a way to change the code. Thanks

Did anyone try to install this plugin in OJS 3.X? We are migrating and the ALM is being a problem, but we need to display a statistic anyway.

Can we have this ojs 3.0.2

It wors on ojs 3.02, see this journal Indonesia Prime, we will try toi implment this here.

I try installing statistic plugin, download and extract file to plugins/generic/ and enable plugin, but when I click statistics menu on main menu show error 404 Not Found. Did I miss something ?

Really this countries are the last in the table. The query have a ASC, chague to DESC
This works fine to me.

function getMetricsByCountryType($journalId, $assoc_type, $year){
$result =& $this->retrieve(
‘SELECT country_id, SUM(metric) FROM metrics WHERE context_id = ? AND assoc_type = ? AND SUBSTR(month,1,4) = ? GROUP BY country_id order by SUM(metric) DESC LIMIT 20;’,
array((int) $journalId, (int) $assoc_type, $year)
);

First patch StatisticPlugin.inc.php
Change this:

function manage($verb, $args, &$message) {
if (!parent::manage($verb, $args, $message)) return false;

For this:

function manage($verb, $args, &$message, &$messageParams) {
if (!parent::manage($verb, $args, $message, $messageParams)) return false;

Then tar the folder, check that the folder name is the same that the class name.

Statistics/

tar -pczf Statistics.tar.gz Statistics/

Then try to install Statistics.tar.gz via Dashboard
User Home > Journal Manager > System Plugins > Install a New Plugin > Select Plugin file

It works for me.

still error 404 not found when acces url Statistics, my code like pict below
Screenshot from 2017-12-15 11-11-07

Sometimes I had errors with coments, try to use // for two line coments or

/**
*
*
*/

Check you version.xml file, it should look llike this:

<version>
        <application>statistics</application>
        <type>plugins.generic</type>
        <release>1.0.0.0</release>
        <date>2016-08-25</date>
        <lazy-load>1</lazy-load>
        <sitewide>1</sitewide>
        <class>StatisticsPlugin</class>
</version>

Did you tar.gz the folder?
Did you remove the statistics folder before trying to install it via Dashbord?
It worked for me once I had removed the whole plugin before I install the Statistic.tar.gz with the OJS dashboard. Worked for me.

Version of Statistics

Screenshot from 2017-12-21 14-30-48

I Installed using command line interface not using Dashboard OJS. Delete old folder then ekstract new statistics file.

You need to use the Dashboard. I had the same issue until I delete the folder and remove the plugin data from the DB. Then I deployed it via Dashboard.
The problem is that OJS2.4 doesn’t register the plugin via parent::register when you copy it via command line, therefore it send you the 404 code.

Hi @htorres09
I tried installing it in ojs 3.1.0 through cpanel plugin/generic

  1. I downloaded the plugin https://github.com/franmanez/statistics then unzipped it.
  2. I changed the codes

function manage($verb, $args, &$message) {
if (!parent::manage($verb, $args, $message)) return false;
for
function manage($verb, $args, &$message, &$messageParams) {
if (!parent::manage($verb, $args, $message, $messageParams)) return false;

then make sure the version.xml

  1. Zip the folder then uploaded to cpanel

After activating the plugin, I open the http://jurnalbeta.ac.id/index.php/betaJTM/statistics
It is just a blank page.

Is only via Dashboard to install this plugin?