[OJS 3.1.2-1] Journal statistic

Hello all,

Some of our journals show statistic and some do not show where we believe they should have some statistic data to show.

Can you one please show me how to troubleshoot this issue? I can take instruction and troubleshoot but I need a pointer from you. I have tried many different things but it just got more confusing. We would like to use Acron plugin to schedule tasks such as collecting Statistic and more…

Attached is the screenshots of stats from different journal.

Kindly thanks to any hint or suggestions.

Dung.

ScreenClipA

ScreenClipB

1 Like

Hi @dung,

Thank you for your question. Could you please confirm which version of OJS you are using and whether these versions are the same for both the journals you have screenshot.

Kind Regards,
Patricia M.
Public Knowledge Project Intern

Hi @pmangahis,

Good to hear from you, we are in current production with version of ojs-3.1.2-1 upgraded from ojs-2.4.8-3.

Best regards,

Dung.

Hi @pmangahis,

I do not know if I should open a new issue, but I think it is best that I put these issues together since they seem to be related in the backend (code) and frontend (js) both.

So beside above issue that some journals display statistic some do not display statistic, I tested Filters and Monthly view and Daily view attached are issue I ran into (see also comments on screenshots for explanation)

I will update with any new findings, we are trying hard to troubleshoot.

Best regards,ScreenClip7

ScreenClip8

ScreenClip9

Dung.

Thanks @pmangahis let me know if I am not clear.

@pmangahis thanks for correcting my title to OJS 3.1.2-1 next time will try to be more specific and details.

Good news! The stats are now logging and displaying for all journals when you go to:
Statistics > Articles
See example: https://journalhosting.ucalgary.ca/index.php/ariel/stats/publishedSubmissions
By adding these base_url lines in config.inc.php

base_url[hic] = “History of Intellectual Culture
base_url[jet] = “Journal of Educational Thought / Revue de la Pensée Educative
base_url[ugrad] = “https://journalhosting.ucalgary.ca/index.php/ugrad
base_url[test] = “https://journalhosting.ucalgary.ca/index.php/test

So we had to state the base_url for each journal, as mentioned by these articles:

After a cron run at 10:08 this morning, the metrics successfully resolved for yesterday.

HOWEVER, there are still error message when displaying different range views or monthly view or daily view of the four custom domain statistics (https://cdm.ucalgary.ca/, https://cjc-rcc.ucalgary.ca/, https://jmss.org/, and https://jhistsex.org).

We are working it. Will post back.

Dung.

This one is of a different kind. I’ve already created an issue for that:

However, @asmecher says “this is probably related to your rewriting configuration; I suspect the API URL is not getting routed to OJS, which is why the server is responding with a 404.” However, I do not know how to set it up properly so the API URL is routed OK :frowning:

P.S. Here is my previous topic for this: [OJS 3.1.2-1] Statistics/Articles wouldn't work properly when base url is set

1 Like

This Monday we will try to test rewrite rules which probably set in apaches config such as under …/ site-available directory. If we can get it working we will share the rules by posting back here. Thank you @Ph_We and other contributors.

Best regards,

Dung.

1 Like

@Ph_We Hi,

We got stats to display correctly now for all custom domains journals (e.g … https://cdm.ucalgary.ca) it was the api url not resolving correctly. To fix this we made the following changes in file: /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:443>
...
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/cdm/$1 [R,L]
...
</VirtualHost>

And don’t forget restarting apache.

D.

1 Like

A quick explanation:

# Before applying the RewriteRules, the below uri is not found error 404
https://jmss.org/api/v1/stats/publishedSubmissions?count=20&offset=0&dateStart=2019-05-20&dateEnd=2019-06-19&timeSegment=month&orderBy=total&orderDirection=DESC&_=1561096128768
# After applying the following RewriteRules, the below uri works
# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/jmss/$1 [R,L]
https://jmss.org/index.php/jmss/api/v1/stats/publishedSubmissions?count=20&offset=0&dateStart=2019-05-20&dateEnd=2019-06-19&timeSegment=month&orderBy=total&orderDirection=DESC&_=1561096128768

Learn RewriteRules here Apache mod_rewrite Introduction - Apache HTTP Server Version 2.4

D.

1 Like

@dung, thank you! However this does not seem to work in our case. And I still suspect there is some bug here. For we have already had a rewriting rule, that should work for all such cases. Here it is:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_NAME} ^mirros.hse.ru$ [NC]
RewriteRule ^(.*)$ index.php/mirros/$1 [L]

I can see the correct call to the API, e.g. when I go to Submissions in the back-end:
image

However, it this does not work when I go to Statistics --> Articles:
image

So we are a bit puzzled now :frowning:

@Ph_We Hi, Where did you put your RewriteRules? Show me the RewriteRules section if you can. Your RewriteRules is wrong in relation to Statistic and you are almost there.

1 Like

It is in the .htaccess:

AcceptPathInfo on
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_NAME} ^[mirros.hse.ru](http://mirros.hse.ru)$ [NC]
RewriteRule ^(.*)$ index.php/mirros/$1 [L]

It is the only RewriteRule we managed to make work for our instance of OJS with multiple journals so far :frowning:

if you read [Solved] Problems with api submissions error on submissions page - #4 by ctgraham
you will see that @ctgraham uses directives at an Apache virtualhost level to simplify the task. Even Apache document said so ( .htaccess files at the expense of some additional complexity.) Apache mod_rewrite Introduction - Apache HTTP Server Version 2.4

I will give you working example for virtual host RewriteRules if you want? Sorry but I will not be able to help with .htaccess RewriteRules.

@Ph_We,

If you want to do RewriteRules in virtualhost sections here is how: in your /etc/apache2/site-enabled/ find your config file such as 000-default.conf and add each section like the below for every journal.

<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerName abcd.org
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/gjhgjgjern

        RewriteEngine On
        # Rewrite index requests to the journal index
        RewriteRule ^/(index.php)?/?$ /index.php/abcd/index [L]

        # Rewrite custom domain to make api calls correctly
        RewriteRule ^/(api/.*)$ /index.php/abcd/$1 [R,L]

        # if the incoming request references the journal shortname, use an external redirect to strip the journal shortname
        RewriteRule ^/abcd/(.*)$ /$1 [R,L]

        # Normal request processing
        # Ignore if this request references index.php already
        RewriteCond %{REQUEST_URI} !/index.php/
        # Ignore if request is for a known OJS directory (Apache 2.2+)
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
        # Ignore if request is for a known OJS file (Apache 2.2+)
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f

        # Otherwise, rewrite all requests through index.php to this specific journal shortname
        RewriteRule ^(.*)$ /index.php/abcd/$1 [QSA,L]

        SSLEngine On
        SSLCertificateFile /sdfdf/asdfdf/cxvxcv/dfsdfds.crt
        SSLCertificateKeyFile /sdfdf/asdfdf/xcvxcvxc/sdfsdfd.key
        SSLCertificateChainFile /sdfds/apsdfs/xcvxcvxc/sfsdfsdfs.crt

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info xcvxcvxcv:warn

        ErrorLog ${APACHE_LOG_DIR}/brwqrwsf_error-xvcxv.log
        CustomLog ${APACHE_LOG_DIR}/sfweradsa_access-dsdsdsa.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
1 Like

Or if you want to stick with RewriteRules in .htaccess you will need to resolve that error 404 Not Found and your Statistic will work, we had the exact same issue and we fixed that with rules:

Rewrite custom domain to make api calls correctly

    RewriteRule ^/(api/.*)$ /index.php/abcd/$1 [R,L]

Where “abcd” is your “mirros”

This is what you api should return then the Stat will show

https://jmss.org/index.php/jmss/api/v1/stats/publishedSubmissions?count=20&offset=0&dateStart=2019-05-20&dateEnd=2019-06-19&timeSegment=month&orderBy=total&orderDirection=DESC&_=1561096128768

Dung.

1 Like

@dung, thank you so much for your help, will try it tomorrow.

1 Like

We’ve only managed to set up rewriting for this certain journal out of 23 so far. And this had to be set up in both .htaccess and VirtualHost. @dung, thanks once again.

@asmecher, (just to make it clear) Is there a reason why this certain API call should be different from any other? It might be really difficult to set this up in some cases.

@Ph_We Hi,

You may try something like this on your .htaccess (you need to target api path because that is your exact problem. Try and that may be it!

# Rewrite custom domain to make api calls correctly
RewriteRule ^/(api/.*)$ /index.php/mirros/$1 [R,L]

AcceptPathInfo on
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_NAME} ^[mirros.hse.ru](http://mirros.hse.ru)$ [NC]
RewriteRule ^(.*)$ index.php/mirros/$1 [L] 

Dung.

1 Like

You only need to set RewriteRules in either Virtualhosts or .Htaccess and not both. Both is confusing. Best in Virtualhosts as mentioned above.

D.

1 Like