Synchronizing the update timing of downloads number and downloads bar graph

Dear Alec Smecher and PKP Forum members,

I’m an engineer of “Jxiv” preprint server system that is based on OPS(Ver.3.3.0.8).
According your advice and direction to Mr.Soichi Kubota who is my colleague, I’ll post it on this forum.
I quote below the email Soichi sent to you on Aug, 2022.

If possible, I would like to be able to execute both A) and B) with “crontab” not with “acron”.

Best regards,
Minoru Tanabe.

Re: Question about statistics from JST (202208)

Hi Soichi,

I’m not the best person on the team to ask this question – but rather than a person-to-person email, could you post this question on our support forum (https://forum.pkp.sfu.ca)? I’ll direct the best person to answer it there. That way we can help build a public knowledge base for other users to benefit from.

Thanks,
Alec

On 2022-08-15 22:38, Soichi Kubota wrote:
Dear Alec and colleagues,

Hello.
I hope this mail finds you well.
I’d like to ask you about the subject.

Now we concerns about the time lag between the following two:

A) update timing of preprints table (# of downloads and accesses) in administrator page
B) update timing of downloads (bar graph) on a preprint landing page

Can we synchronize the two?
If possible, could you please tell us how?
A) is carried out with acron so we can adjust the timing but we do not know what is the trigger of B).

Thank you for your support.

Best regards,
Soichi

Hi @Minoru_Tanabe,

Could you please tell me what exactly A) update timing of preprints table (# of downloads and accesses) in administrator page means? What page do you mean?

Thanks a lot!
Bozana

Hi @bozana ,

Thank you for your reply.
Sorry for our vague description.
To be precise, A) is the preprint list page and B) is the preprint details page.
Both are landing pages. Not an admin page.

Screen samples of A) and B) are attached below.
Sample of A)
sample_A

Sample of B)
sample_B

As you can see, the number of downloads for A) is “66” and for B) is “65”. Then, after about half a day, B) will change to 66.

Best,
Minoru Tanabe.

The numbers for the preprint listing (A) are get directly from the DB.
The graph on the preprint landing page (B) uses the daily cached statistics/numbers – taken/actualized from the DB daily (s. usageStats/UsageStatsPlugin.inc.php at stable-3_3_0 · pkp/usageStats · GitHub). The cache file is called fc-downloadStats-{preprintId}.php.
The numbers are calculated and stored in the DB with the scheduled task, that you run via a cron job, as far as I understand.
So maybe you could synchronize the two if you remove the cache files immediately after the scheduled task is run. This way the next time a user visits a preprint landing page the numbers for the graph will be read from the DB (which should then be the same as for the preprint listing) and then saved in the cache file.

I hope that this helps.
Best,
Bozana

Hi @bozana ,

Thanks to your explanation, I understand how the aggregation of (A) and (B) works.
I actually cleared the cache and confirmed that the number of downloads matches the number on the download chart.

So, I have another question, I would like to stop using Acron and use Crontab to aggregate (A), please tell me how to do that.
I know about registering task commands to Crontab (*), should I disable the “Acron Plugin” to stop Acron?

(*) Commands to set in crontab.
# cp -p ./files/usageStats/usageEventLogs/usage_events_YYYYMMDD.log ./files/usageStats/stage/
# php runScheduledTasks.php ./ops/plugins/generic/usageStats/scheduledTasks.xml

Thanks lot,
Minoru Tanabe

Hi @Minoru_Tanabe,

Yes, you would need to disable Acron Plugin. Thus, you would need to move all the scheduled tasks that you use to Cron. This one, for example: ops/scheduledTasks.xml at stable-3_3_0 · pkp/ops · GitHub. But there are maybe other in your installation as well. You can see them in the DB table plugin_settings where plugin_name=acronplugin.

Regarding your crontab:
The runScheduledTasks.php is in the folder tool/.
And you can also use plugins/generic/usageStats/scheduledTasksAutoStage.xml – then you do not need to copy the log files to the stage folder, the scheduled task will do it automatically. Please, test it before…

Check then all changes regarding scheduled tasks and adapt when doing an upgrade…

Best,
Bozana

Hi @bozana ,

Thank you for your advice and support on stopping acron and setting crontab.
After confirming the DB table “plugin_settings” and “scheduledTasksAutoStage.xml”, I will test the crontab and migrate scheduled tasks from acron to crontab.

I deeply grateful for your support, thanks!
Minoru Tanabe