Bugzilla – Attachment 133914 Details for
Bug 30275
Checkout renewals should be stored in their own table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30275: Rename issues.renewals to issues.renewals_count
Bug-30275-Rename-issuesrenewals-to-issuesrenewalsc.patch (text/plain), 13.99 KB, created by
Martin Renvoize (ashimema)
on 2022-04-26 14:42:21 UTC
(
hide
)
Description:
Bug 30275: Rename issues.renewals to issues.renewals_count
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-04-26 14:42:21 UTC
Size:
13.99 KB
patch
obsolete
>From 066d5a8ca302de7d700aaa464165deac4b59d5a8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 11 Mar 2022 15:04:06 +0000 >Subject: [PATCH] Bug 30275: Rename issues.renewals to issues.renewals_count > >Rename the issues.renewals field to renewals_count to prevent a method >name collision with the new relation accessor introduced by this >patchset. >--- > C4/Circulation.pm | 10 +++++----- > C4/ILSDI/Services.pm | 2 +- > C4/Members.pm | 4 ++-- > Koha/REST/V1/Checkouts.pm | 2 +- > api/v1/swagger/definitions/checkout.yaml | 2 +- > installer/data/mysql/atomicupdate/bug_30275.pl | 6 ++++++ > installer/data/mysql/kohastructure.sql | 4 ++-- > .../prog/en/modules/catalogue/issuehistory.tt | 2 +- > .../prog/en/modules/members/readingrec.tt | 2 +- > misc/recreateIssueStatistics.pl | 6 +++--- > offline_circ/download.pl | 2 +- > t/db_dependent/SIP/ILS.t | 4 ++-- > 12 files changed, 26 insertions(+), 20 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 1b0fed3366..076f1eda8d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2869,7 +2869,7 @@ sub CanBookBeRenewed { > ); > > return ( 0, "too_many" ) >- if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals; >+ if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals_count; > > return ( 0, "too_unseen" ) > if C4::Context->preference('UnseenRenewals') && >@@ -3125,8 +3125,8 @@ sub AddRenewal { > > # Update the issues record to have the new due date, and a new count > # of how many times it has been renewed. >- my $renews = ( $issue->renewals || 0 ) + 1; >- my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?"); >+ my $renews = ( $issue->renewals_count || 0 ) + 1; >+ my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals_count = ?, unseen_renewals = ?, lastreneweddate = ? WHERE issue_id = ?"); > > eval{ > $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $issue->issue_id ); >@@ -3254,7 +3254,7 @@ sub GetRenewCount { > ); > $sth->execute( $bornum, $itemno ); > my $data = $sth->fetchrow_hashref; >- $renewcount = $data->{'renewals'} if $data->{'renewals'}; >+ $renewcount = $data->{'renewals_count'} if $data->{'renewals_count'}; > $unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'}; > # $item and $borrower should be calculated > my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); >@@ -4048,7 +4048,7 @@ sub ProcessOfflineReturn { > $itemnumber, > $operation->{timestamp}, > ); >- $item->renewals(0); >+ $item->renewals_count(0); > $item->onloan(undef); > $item->store({ log_action => 0 }); > return "Success."; >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 76632283c6..ec1480c426 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -694,7 +694,7 @@ sub RenewLoan { > > # Hashref building > my $out; >- $out->{'renewals'} = $issue->renewals; >+ $out->{'renewals'} = $issue->renewals_count; > $out->{date_due} = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M'); > $out->{'success'} = $renewal[0]; > $out->{'error'} = $renewal[1]; >diff --git a/C4/Members.pm b/C4/Members.pm >index 0919ac9883..5478e0de32 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -266,7 +266,7 @@ sub GetAllIssues { > > my $dbh = C4::Context->dbh; > my $query = >-'SELECT issues.*, items.*, biblio.*, biblioitems.*, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname >+'SELECT issues.*, items.*, biblio.*, biblioitems.*, issues.timestamp as issuestimestamp, issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname > FROM issues > LEFT JOIN items on items.itemnumber=issues.itemnumber > LEFT JOIN borrowers on borrowers.borrowernumber=issues.issuer_id >@@ -274,7 +274,7 @@ sub GetAllIssues { > LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber > WHERE issues.borrowernumber=? > UNION ALL >- SELECT old_issues.*, items.*, biblio.*, biblioitems.*, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname >+ SELECT old_issues.*, items.*, biblio.*, biblioitems.*, old_issues.timestamp as issuestimestamp, old_issues.renewals_count AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp,borrowers.firstname,borrowers.surname > FROM old_issues > LEFT JOIN items on items.itemnumber=old_issues.itemnumber > LEFT JOIN borrowers on borrowers.borrowernumber=old_issues.issuer_id >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index e670987bff..b00469879a 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -193,7 +193,7 @@ sub allows_renewal { > openapi => { > allows_renewal => $renewable, > max_renewals => $rule->rule_value, >- current_renewals => $checkout->renewals, >+ current_renewals => $checkout->renewals_count, > unseen_renewals => $checkout->unseen_renewals, > error => $error > } >diff --git a/api/v1/swagger/definitions/checkout.yaml b/api/v1/swagger/definitions/checkout.yaml >index 9ea807224d..e2a4d733ca 100644 >--- a/api/v1/swagger/definitions/checkout.yaml >+++ b/api/v1/swagger/definitions/checkout.yaml >@@ -36,7 +36,7 @@ properties: > - "null" > format: date-time > description: Date the item was last renewed >- renewals: >+ renewals_count: > type: > - integer > - "null" >diff --git a/installer/data/mysql/atomicupdate/bug_30275.pl b/installer/data/mysql/atomicupdate/bug_30275.pl >index b567dfb852..a77882c0dc 100755 >--- a/installer/data/mysql/atomicupdate/bug_30275.pl >+++ b/installer/data/mysql/atomicupdate/bug_30275.pl >@@ -21,6 +21,12 @@ return { > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > }); > say $out "Added new table 'checkout_renewals'"; >+ >+ $dbh->do(q{ ALTER TABLE `issues` CHANGE `renewals` `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed' }); >+ say $out "Renamed `issues.renewals` to `issues.renewals_count`"; >+ >+ $dbh->do(q{ ALTER TABLE `old_issues` CHANGE `renewals` `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed' }); >+ say $out "Renamed `old_issues.renewals` to `old_issues.renewals_count`"; > } > }, > } >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index f431b69ea9..acc5fe2e52 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3011,7 +3011,7 @@ CREATE TABLE `issues` ( > `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out', > `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues', > `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed', >- `renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', >+ `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', > `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen', > `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal', > `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error', >@@ -3910,7 +3910,7 @@ CREATE TABLE `old_issues` ( > `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out', > `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned', > `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed', >- `renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', >+ `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed', > `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen', > `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal', > `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt >index 53c0121d52..836a4782e8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt >@@ -90,7 +90,7 @@ > [% INCLUDE 'patron-title.inc' patron=checkout.issuer %] > </a> > [% END %]</td> >- <td>[% IF checkout.renewals %] >+ <td>[% IF checkout.renewals_count %] > Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1 %]</small> > [% END %] > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >index 3acc84e067..6d348fb2e8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >@@ -109,7 +109,7 @@ > </td> > > <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% issue.itemnumber | uri %]&biblionumber=[% issue.biblionumber | uri %]&bi=[% issue.biblioitemnumber | uri %]#item[% issue.itemnumber | uri %]">[% issue.barcode | html %]</a></td> >- <td>[% issue.renewals | html %]</td> >+ <td>[% issue.renewals_count | html %]</td> > <td data-order="[% issue.issuedate | html %]"> > [% issue.issuedate |$KohaDates with_hours => 1 %] > </td> >diff --git a/misc/recreateIssueStatistics.pl b/misc/recreateIssueStatistics.pl >index 859cf02a5e..939b4df168 100755 >--- a/misc/recreateIssueStatistics.pl >+++ b/misc/recreateIssueStatistics.pl >@@ -60,7 +60,7 @@ if ($issues == 1) { > foreach my $table ('issues', 'old_issues') { > # Getting issues > print "looking for missing issues from $table\n"; >- my $query = "SELECT borrowernumber, branchcode, itemnumber, issuedate, renewals, lastreneweddate from $table where itemnumber is not null"; >+ my $query = "SELECT borrowernumber, branchcode, itemnumber, issuedate, renewals_count, lastreneweddate from $table where itemnumber is not null"; > my $sth = $dbh->prepare($query); > $sth->execute; > # Looking for missing issues >@@ -92,7 +92,7 @@ if ($issues == 1) { > } > > # Looking for missing renewals >- if ($hashref->{'renewals'} && $hashref->{'renewals'} > 0 ) { >+ if ($hashref->{'renewals_count'} && $hashref->{'renewals_count'} > 0 ) { > # This is the not-so accurate part : > # We assume that there are missing renewals, based on the last renewal date > # Maybe should this be deactivated by default ? >@@ -100,7 +100,7 @@ if ($issues == 1) { > my $substh = $dbh->prepare($ctnquery); > $substh->execute($hashref->{'borrowernumber'}, $hashref->{'itemnumber'}, $hashref->{'lastreneweddate'}); > >- my $missingrenewalscount = $hashref->{'renewals'} - $substh->fetchrow_hashref->{'cnt'}; >+ my $missingrenewalscount = $hashref->{'renewals_count'} - $substh->fetchrow_hashref->{'cnt'}; > print "We assume $missingrenewalscount renewals are missing. Creating them\n" if ($missingrenewalscount > 0); > for (my $i = 0; $i < $missingrenewalscount; $i++) { > >diff --git a/offline_circ/download.pl b/offline_circ/download.pl >index 10272cbc3f..ad120fd766 100755 >--- a/offline_circ/download.pl >+++ b/offline_circ/download.pl >@@ -66,7 +66,7 @@ my $issues_query = q{SELECT > items.itemcallnumber AS callnumber, > issues.date_due AS date_due, > issues.issuedate AS issuedate, >- issues.renewals AS renewals, >+ issues.renewals_count AS renewals, > issues.unseen_renewals AS unseen_renewals, > borrowers.cardnumber AS cardnumber, > CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name >diff --git a/t/db_dependent/SIP/ILS.t b/t/db_dependent/SIP/ILS.t >index c117e53763..abc441a748 100755 >--- a/t/db_dependent/SIP/ILS.t >+++ b/t/db_dependent/SIP/ILS.t >@@ -275,7 +275,7 @@ subtest checkout => sub { > AddIssue( $patron->unblessed, $item->barcode, undef, 0 ); > my $checkout = $item->checkout; > ok( defined($checkout), "Checkout added"); >- is( $checkout->renewals, 0, "Correct renewals"); >+ is( $checkout->renewals_count, 0, "Correct renewals"); > > my $ils = C4::SIP::ILS->new({ id => $library->branchcode }); > my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >@@ -284,7 +284,7 @@ subtest checkout => sub { > is( $transaction->{screen_msg},"Item already checked out to you: renewing item.","We get a success message when issue is renewed"); > > $checkout->discard_changes(); >- is( $checkout->renewals, 1, "Renewals has been reduced"); >+ is( $checkout->renewals_count, 1, "Renewals has been reduced"); > }; > > subtest renew_all => sub { >-- >2.20.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 30275
:
131593
|
131594
|
131595
|
131596
|
131597
|
131598
|
131599
|
131600
|
131601
|
131602
|
131603
|
131604
|
131605
|
131606
|
131607
|
131608
|
131609
|
131610
|
131611
|
131612
|
131613
|
131614
|
131615
|
131616
|
131879
|
131880
|
131881
|
131882
|
131883
|
131884
|
131885
|
131886
|
131887
|
131888
|
131889
|
131890
|
131897
|
131898
|
131899
|
131900
|
131901
|
131902
|
131903
|
131904
|
131905
|
131906
|
131907
|
131908
|
131909
|
131910
|
133908
|
133909
|
133910
|
133911
|
133912
|
133913
|
133914
|
133915
|
133916
|
133917
|
133918
|
133919
|
133920
|
133921
|
133922
|
133929
|
133930
|
133931
|
133932
|
133933
|
133934
|
133935
|
133936
|
133937
|
133938
|
133939
|
133940
|
133941
|
133942
|
133943
|
133944
|
133969
|
133970
|
133971
|
133972
|
133973
|
133974
|
133975
|
133976
|
133977
|
133978
|
133979
|
133980
|
133981
|
133982
|
133983
|
133984
|
134177
|
134178
|
134179
|
134180
|
134181
|
134182
|
134183
|
134184
|
134185
|
134186
|
134187
|
134188
|
134189
|
134190
|
134191
|
134192
|
134193
|
134210
|
134228
|
134229
|
134230
|
134231
|
134232
|
134233
|
134234
|
134235
|
134236
|
134237
|
134238
|
134239
|
134240
|
134241
|
134242
|
134243
|
134244
|
134245
|
134246
|
134247
|
134248
|
134470
|
134471
|
134472
|
134473
|
134869
|
134870
|
134871
|
134872
|
134873
|
134874
|
134875
|
134876
|
134877
|
134878
|
134879
|
134880
|
134881
|
134882
|
134883
|
134884
|
134885
|
134886
|
134887
|
134888
|
134889
|
135123
|
135124
|
135125
|
135126
|
135127
|
135128
|
135129
|
135130
|
135131
|
135132
|
135133
|
135134
|
135135
|
135136
|
135137
|
135138
|
135139
|
135140
|
135141
|
135142
|
135143
|
137146
|
137147
|
137148
|
137149
|
137150
|
137151
|
137152
|
137153
|
137154
|
137155
|
137156
|
137157
|
137158
|
137159
|
137160
|
137161
|
137162
|
137163
|
137164
|
137165
|
137166
|
137217
|
137598