Bug 38104

Summary: share_usage_with_koha_community.pl: Check between two runs should be a bit lower than 30d
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Command-line UtilitiesAssignee: Marcel de Rooy <m.de.rooy>
Status: BLOCKED --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: david, phil, robin
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 38104: Adjust number of seconds in UsageStats::NeedUpdate

Description Marcel de Rooy 2024-10-07 09:05:13 UTC
From production data:

HEA preference: 1725159125
select FROM_UNIXTIME( 1725159125 );
| 2024-09-01 04:52:05         |

select * from action_logs where timestamp>'2024-10-01' and module='CRONJOBS' and script like '%usage%';
|   7429456 | 2024-10-01 04:52:04 |    0 | CRONJOBS | Run    | 116996 | /usr/share/koha/misc/cronjobs/share_usage_with_koha_community.pl           | cron      | share_usage_with_koha_community.pl |
|   7429457 | 2024-10-01 04:52:04 |    0 | CRONJOBS | End    | 116996 | /usr/share/koha/misc/cronjobs/share_usage_with_koha_community.pl COMPLETED | cron      | share_usage_with_koha_community.pl |

So the HEA update was skipped since the script was 1 second too early :)
Comment 1 Marcel de Rooy 2024-10-07 09:06:12 UTC
Since we run this script from cron.monthly, it would be enough to check for say four weeks.
Comment 2 Marcel de Rooy 2024-10-07 09:30:04 UTC
Created attachment 172447 [details] [review]
Bug 38104: Adjust number of seconds in UsageStats::NeedUpdate

Test plan:
Check pref UsageStatsLastUpdateTime
Run perl -MC4::UsageStats -e'print C4::UsageStats::NeedUpdate()'
Verify that it prints 1 only if time interval exceeds 4 weeks.
Temporarily clear this pref.
Run again. Should always print 1 now.
Restore pref value.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Phil Ringnalda 2024-10-25 13:46:07 UTC
Isn't that still risky for March 1st being run 2419199 seconds after February 1st?
Comment 4 David Nind 2024-10-26 19:02:50 UTC
Could you be a bit more specific in the test plan how to test this, please?

- There is no UsageStatsLastUpdateTime system preference (in main).
- Do I apply the patch first?
- Do I need to configure Administration > Additional parameters > Share your usage statistics?

Shouldn't the commit message have a description, as per the commit message guidelines? (https://wiki.koha-community.org/wiki/Commit_messages#Bug.2Ffeature_description)
Comment 5 Marcel de Rooy 2024-10-28 14:23:21 UTC
(In reply to Phil Ringnalda from comment #3)
> Isn't that still risky for March 1st being run 2419199 seconds after
> February 1st?

Yeah good point. Currently an issue too..
Comment 6 Marcel de Rooy 2024-10-28 14:25:54 UTC
(In reply to David Nind from comment #4)
> Could you be a bit more specific in the test plan how to test this, please?
> 
> - There is no UsageStatsLastUpdateTime system preference (in main).
Local prefs.
> - Do I apply the patch first?
> - Do I need to configure Administration > Additional parameters > Share your
> usage statistics?
Yeah. Needs to be enabled. Will add a step to insert some last update time in the test plan.

> Shouldn't the commit message have a description, as per the commit message
> guidelines?
> (https://wiki.koha-community.org/wiki/Commit_messages#Bug.
> 2Ffeature_description)

This is about 2 lines of code. So imo covered by the title..
Not uncommon to see.