Bugzilla – Attachment 176957 Details for
Bug 38104
share_usage_with_koha_community.pl: Check between two runs is not needed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[ALTERNATIVE-PATCH] Bug 38104: Always update when hea cronjob is run
Bug-38104-Always-update-when-hea-cronjob-is-run.patch (text/plain), 4.00 KB, created by
Jonathan Druart
on 2025-01-23 13:35:33 UTC
(
hide
)
Description:
[ALTERNATIVE-PATCH] Bug 38104: Always update when hea cronjob is run
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-01-23 13:35:33 UTC
Size:
4.00 KB
patch
obsolete
>From 01f7c42fc58f4f1ac857224939a4b7039707b092 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 23 Jan 2025 14:34:30 +0100 >Subject: [PATCH] Bug 38104: Always update when hea cronjob is run > >If the cronjob is configured to run every month we don't need to add >another test on the delay in the script itself. >--- > C4/UsageStats.pm | 19 --------------- > .../share_usage_with_koha_community.pl | 18 +++++--------- > t/db_dependent/UsageStats.t | 24 ++----------------- > 3 files changed, 8 insertions(+), 53 deletions(-) > >diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm >index 37b4a76ec4f..8f55c261bdc 100644 >--- a/C4/UsageStats.pm >+++ b/C4/UsageStats.pm >@@ -36,27 +36,8 @@ hea.koha-community.org is the server that centralize Koha setups informations > Koha libraries are encouraged to provide informations about their collections, > their structure,... > >-=head2 NeedUpdate >- >- $needUpdateYN = C4::UsageStats::NeedUpdate; >- >-Returns Y (1) if the last update is more than 1 month old >-This way, even if the cronjob is run every minute, the webservice will be called >-only once a month ! >- > =cut > >-sub NeedUpdate { >- my $lastupdated = C4::Context->preference('UsageStatsLastUpdateTime') || 0; >- my $now = strftime( "%s", localtime ); >- >- # Need to launch cron. >- return 1 if $now - $lastupdated >= 2592000; >- >- # Data don't need to be updated >- return 0; >-} >- > sub BuildReport { > my $report; > my @libraries; >diff --git a/misc/cronjobs/share_usage_with_koha_community.pl b/misc/cronjobs/share_usage_with_koha_community.pl >index c534bdb1e70..be680356461 100755 >--- a/misc/cronjobs/share_usage_with_koha_community.pl >+++ b/misc/cronjobs/share_usage_with_koha_community.pl >@@ -39,18 +39,12 @@ Setting the quiet flag will silence this message. > exit 1; > } > >-my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() ); >- >-if ($need_update) { >- say "Data need to be updated" if $verbose; >- my $report = C4::UsageStats::BuildReport(); >- C4::UsageStats::ReportToCommunity($report); >- C4::Context->set_preference( 'UsageStatsLastUpdateTime', >- strftime( "%s", localtime ) ); >-} >-elsif ($verbose) { >- say "Data don't need to be updated"; >-} >+my $report = C4::UsageStats::BuildReport(); >+C4::UsageStats::ReportToCommunity($report); >+C4::Context->set_preference( >+ 'UsageStatsLastUpdateTime', >+ strftime( "%s", localtime ) >+); > > cronlogaction({ action => 'End', info => "COMPLETED" }); > >diff --git a/t/db_dependent/UsageStats.t b/t/db_dependent/UsageStats.t >index 90bd7e10780..2d72af35d5d 100755 >--- a/t/db_dependent/UsageStats.t >+++ b/t/db_dependent/UsageStats.t >@@ -16,7 +16,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 3; > > use t::lib::Mocks qw(mock_preference); > use t::lib::TestBuilder; >@@ -33,12 +33,11 @@ use Koha::Old::Holds; > use Koha::Patrons; > > BEGIN { >- use_ok('C4::UsageStats', qw( NeedUpdate BuildReport ReportToCommunity _count )); >+ use_ok('C4::UsageStats', qw( BuildReport ReportToCommunity _count )); > } > > can_ok( > 'C4::UsageStats', qw( >- NeedUpdate > BuildReport > ReportToCommunity > _count ) >@@ -47,25 +46,6 @@ can_ok( > my $builder = t::lib::TestBuilder->new; > my $schema = Koha::Database->new->schema; > >-subtest 'NeedUpdate() tests' => sub { >- >- plan tests => 2; >- >- #Mocking C4::Context->preference("UsageStatsLastUpdateTime") to 0 >- my $now = strftime( "%s", localtime ); >- t::lib::Mocks::mock_preference( "UsageStatsLastUpdateTime", 0 ); >- >- my $update = C4::UsageStats->NeedUpdate; >- is( $update, 1, "There is no last update, update needed" ); >- >- #Mocking C4::Context->preference("UsageStatsLastUpdateTime") to now >- $now = strftime( "%s", localtime ); >- t::lib::Mocks::mock_preference( "UsageStatsLastUpdateTime", $now ); >- >- $update = C4::UsageStats->NeedUpdate; >- is( $update, 0, "Last update just be done, no update needed " ); >-}; >- > subtest 'BuildReport() tests' => sub { > > plan tests => 30; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38104
:
172447
|
176674
|
176702
|
176957
|
177096