From 6a2a80988dd121215284c4458438fdb0fe41b86c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Aug 2018 12:01:56 -0300 Subject: [PATCH] Bug 21235: Remove table services_throttle This table was only used by XISBN, this patch remove the table and the related code (cronjobs) Signed-off-by: Kyle M Hall https://bugs.koha-community.org/show_bug.cgi?id=21235 Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- C4/XISBN.pm | 28 ----------- Koha/Schema/Result/ServicesThrottle.pm | 66 -------------------------- debian/koha-common.cron.daily | 1 - installer/data/mysql/kohastructure.sql | 11 ----- misc/cronjobs/crontab.example | 3 -- misc/cronjobs/services_throttle.pl | 21 -------- 6 files changed, 130 deletions(-) delete mode 100644 Koha/Schema/Result/ServicesThrottle.pm delete mode 100755 misc/cronjobs/services_throttle.pl diff --git a/C4/XISBN.pm b/C4/XISBN.pm index 7562d68eb9..22b450255b 100644 --- a/C4/XISBN.pm +++ b/C4/XISBN.pm @@ -141,34 +141,6 @@ sub _get_url { } - -# Throttle services to the specified amount -sub _service_throttle { - my ($service_type,$daily_limit) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare(q{ SELECT service_count FROM services_throttle WHERE service_type=? }); - $sth->execute($service_type); - my $count = 0; - - if ($sth->rows == 0) { - # initialize services throttle - my $sth2 = $dbh->prepare(q{ INSERT INTO services_throttle (service_type, service_count) VALUES (?, ?) }); - $sth2->execute($service_type, $count); - } else { - $count = $sth->fetchrow_array; - } - - # we're over the limit - return 1 if $count >= $daily_limit; - - # not over the limit - $count++; - my $sth3 = $dbh->prepare(q{ UPDATE services_throttle SET service_count=? WHERE service_type=? }); - $sth3->execute($count, $service_type); - - return undef; -} - 1; __END__ diff --git a/Koha/Schema/Result/ServicesThrottle.pm b/Koha/Schema/Result/ServicesThrottle.pm deleted file mode 100644 index d9e34e4f2b..0000000000 --- a/Koha/Schema/Result/ServicesThrottle.pm +++ /dev/null @@ -1,66 +0,0 @@ -use utf8; -package Koha::Schema::Result::ServicesThrottle; - -# Created by DBIx::Class::Schema::Loader -# DO NOT MODIFY THE FIRST PART OF THIS FILE - -=head1 NAME - -Koha::Schema::Result::ServicesThrottle - -=cut - -use strict; -use warnings; - -use base 'DBIx::Class::Core'; - -=head1 TABLE: C - -=cut - -__PACKAGE__->table("services_throttle"); - -=head1 ACCESSORS - -=head2 service_type - - data_type: 'varchar' - default_value: (empty string) - is_nullable: 0 - size: 10 - -=head2 service_count - - data_type: 'varchar' - is_nullable: 1 - size: 45 - -=cut - -__PACKAGE__->add_columns( - "service_type", - { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, - "service_count", - { data_type => "varchar", is_nullable => 1, size => 45 }, -); - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=cut - -__PACKAGE__->set_primary_key("service_type"); - - -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XxtEV+cJ5qa/3oCHd2GrSw - - -# You can replace this text with custom content, and it will be preserved on regeneration -1; diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily index 50d49d8a83..63eb0707b0 100644 --- a/debian/koha-common.cron.daily +++ b/debian/koha-common.cron.daily @@ -22,7 +22,6 @@ koha-foreach --chdir --enabled --email /usr/share/koha/bin/cronjobs/advance_noti koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/serialsUpdate.pl -c koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/membership_expiry.pl -c koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.pl >/dev/null 2>&1 -koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/null 2>&1 koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1 diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index cdc97fed38..3048ade972 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2325,17 +2325,6 @@ CREATE TABLE `zebraqueue` ( KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; --- --- Table structure for table `services_throttle` --- - -DROP TABLE IF EXISTS `services_throttle`; -CREATE TABLE `services_throttle` ( - `service_type` varchar(10) NOT NULL default '', - `service_count` varchar(45) default NULL, - PRIMARY KEY (`service_type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -- -- Table structure for table `language_subtag_registry` -- http://www.w3.org/International/articles/language-tags/ diff --git a/misc/cronjobs/crontab.example b/misc/cronjobs/crontab.example index db1c703c3c..80c1d9eeba 100644 --- a/misc/cronjobs/crontab.example +++ b/misc/cronjobs/crontab.example @@ -83,9 +83,6 @@ KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs # for both authorities and bibs */10 * * * * __KOHA_USER__ $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null -# services_throttle -- resets the xISBN service -59 23 * * * __KOHA_USER__ $KOHA_CRON_PATH/services_throttle.pl > /dev/null 2>&1 - # clean up databases nightly. Be sure not to run this with --sessions during a time when the system is in use! 16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads diff --git a/misc/cronjobs/services_throttle.pl b/misc/cronjobs/services_throttle.pl deleted file mode 100755 index cafc5171cf..0000000000 --- a/misc/cronjobs/services_throttle.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/perl -# run nightly -- resets the xisbn services throttle - -use strict; -use warnings; - -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/../kohalib.pl" }; -} - -use C4::Context; -my $fixit="UPDATE services_throttle SET service_count=0 WHERE service_type='xisbn'"; -my $sth = C4::Context->dbh->prepare($fixit); -my $res = $sth->execute() or die "cannot execute query: $fixit"; - -# There is no need to return anything if we succeeded, -# and the die message (or other more internal Context/mysql error) -# will get emailed to the cron user if we didn't. -- 2.39.5