View | Details | Raw Unified | Return to bug 21226
Collapse All | Expand All

(-)a/C4/XISBN.pm (-28 lines)
Lines 141-174 sub _get_url { Link Here
141
141
142
}
142
}
143
143
144
145
# Throttle services to the specified amount
146
sub _service_throttle {
147
    my ($service_type,$daily_limit) = @_;
148
    my $dbh = C4::Context->dbh;
149
    my $sth = $dbh->prepare(q{ SELECT service_count FROM services_throttle WHERE service_type=? });
150
    $sth->execute($service_type);
151
    my $count = 0;
152
153
    if ($sth->rows == 0) {
154
        # initialize services throttle
155
        my $sth2 = $dbh->prepare(q{ INSERT INTO services_throttle (service_type, service_count) VALUES (?, ?) });
156
        $sth2->execute($service_type, $count);
157
    } else {
158
        $count = $sth->fetchrow_array;
159
    }
160
161
    # we're over the limit
162
    return 1 if $count >= $daily_limit;
163
164
    # not over the limit
165
    $count++;
166
    my $sth3 = $dbh->prepare(q{ UPDATE services_throttle SET service_count=? WHERE service_type=? });
167
    $sth3->execute($count, $service_type);
168
169
    return undef;
170
}
171
172
1;
144
1;
173
__END__
145
__END__
174
146
(-)a/Koha/Schema/Result/ServicesThrottle.pm (-66 lines)
Lines 1-66 Link Here
1
use utf8;
2
package Koha::Schema::Result::ServicesThrottle;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::ServicesThrottle
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<services_throttle>
19
20
=cut
21
22
__PACKAGE__->table("services_throttle");
23
24
=head1 ACCESSORS
25
26
=head2 service_type
27
28
  data_type: 'varchar'
29
  default_value: (empty string)
30
  is_nullable: 0
31
  size: 10
32
33
=head2 service_count
34
35
  data_type: 'varchar'
36
  is_nullable: 1
37
  size: 45
38
39
=cut
40
41
__PACKAGE__->add_columns(
42
  "service_type",
43
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 },
44
  "service_count",
45
  { data_type => "varchar", is_nullable => 1, size => 45 },
46
);
47
48
=head1 PRIMARY KEY
49
50
=over 4
51
52
=item * L</service_type>
53
54
=back
55
56
=cut
57
58
__PACKAGE__->set_primary_key("service_type");
59
60
61
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
62
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XxtEV+cJ5qa/3oCHd2GrSw
63
64
65
# You can replace this text with custom content, and it will be preserved on regeneration
66
1;
(-)a/debian/koha-common.cron.daily (-1 lines)
Lines 22-28 koha-foreach --chdir --enabled --email /usr/share/koha/bin/cronjobs/advance_noti Link Here
22
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/serialsUpdate.pl -c
22
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/serialsUpdate.pl -c
23
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/membership_expiry.pl -c
23
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/membership_expiry.pl -c
24
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.pl >/dev/null 2>&1
24
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.pl >/dev/null 2>&1
25
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/services_throttle.pl > /dev/null 2>&1
26
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
25
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
27
koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
26
koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --mail
28
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1
27
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1
(-)a/installer/data/mysql/atomicupdate/bug_21226 (+1 lines)
Lines 1-3 Link Here
1
DELETE FROM systempreferences where variable="OCLCAffiliateID";
1
DELETE FROM systempreferences where variable="OCLCAffiliateID";
2
DELETE FROM systempreferences where variable="XISBN";
2
DELETE FROM systempreferences where variable="XISBN";
3
DELETE FROM systempreferences where variable="XISBNDailyLimit";
3
DELETE FROM systempreferences where variable="XISBNDailyLimit";
4
DROP TABLE IF EXISTS services_throttle;
(-)a/installer/data/mysql/kohastructure.sql (-11 lines)
Lines 2341-2357 CREATE TABLE `zebraqueue` ( Link Here
2341
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2341
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2342
2342
2343
--
2343
--
2344
-- Table structure for table `services_throttle`
2345
--
2346
2347
DROP TABLE IF EXISTS `services_throttle`;
2348
CREATE TABLE `services_throttle` (
2349
  `service_type` varchar(10) NOT NULL default '',
2350
  `service_count` varchar(45) default NULL,
2351
  PRIMARY KEY  (`service_type`)
2352
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2353
2354
--
2355
-- Table structure for table `language_subtag_registry`
2344
-- Table structure for table `language_subtag_registry`
2356
-- http://www.w3.org/International/articles/language-tags/
2345
-- http://www.w3.org/International/articles/language-tags/
2357
-- RFC4646
2346
-- RFC4646
(-)a/misc/cronjobs/crontab.example (-3 lines)
Lines 83-91 KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs Link Here
83
# for both authorities and bibs
83
# for both authorities and bibs
84
*/10 * * * *  __KOHA_USER__  $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null
84
*/10 * * * *  __KOHA_USER__  $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null
85
85
86
# services_throttle -- resets the xISBN service
87
59 23 * * *  __KOHA_USER__ $KOHA_CRON_PATH/services_throttle.pl > /dev/null 2>&1
88
89
# clean up databases nightly.  Be sure not to run this with --sessions during a time when the system is in use!
86
# clean up databases nightly.  Be sure not to run this with --sessions during a time when the system is in use!
90
16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
87
16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads
91
88
(-)a/misc/cronjobs/services_throttle.pl (-22 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
2
# run nightly -- resets the xisbn services throttle
3
4
use strict;
5
use warnings;
6
7
BEGIN {
8
    # find Koha's Perl modules
9
    # test carefully before changing this
10
    use FindBin;
11
    eval { require "$FindBin::Bin/../kohalib.pl" };
12
}
13
14
use C4::Context;
15
my $fixit="UPDATE services_throttle SET service_count=0 WHERE service_type='xisbn'";
16
my $sth = C4::Context->dbh->prepare($fixit);
17
my $res = $sth->execute() or die "cannot execute query: $fixit";
18
19
# There is no need to return anything if we succeeded, 
20
# and the die message (or other more internal Context/mysql error) 
21
# will get emailed to the cron user if we didn't.
22
- 

Return to bug 21226