Bugzilla – Attachment 157449 Details for
Bug 33608
Allow to get statistics about found/recovered books
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33608: (QA follow-up) Remove ->insert method
Bug-33608-QA-follow-up-Remove--insert-method.patch (text/plain), 4.53 KB, created by
Marcel de Rooy
on 2023-10-19 14:10:30 UTC
(
hide
)
Description:
Bug 33608: (QA follow-up) Remove ->insert method
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-10-19 14:10:30 UTC
Size:
4.53 KB
patch
obsolete
>From 7b95320046a09d3e90180916d357d49a9e6a1a43 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 19 Oct 2023 13:50:59 +0000 >Subject: [PATCH] Bug 33608: (QA follow-up) Remove ->insert method >Content-Type: text/plain; charset=utf-8 > >Might come back on the subject when resuming with bug 33636. > >Test plan: >Run t/db_dependent/Koha/Statistics.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] Tidy Koha/Item.pm bit further. Ordered hash keys too. >--- > C4/Stats.pm | 4 ++-- > Koha/Item.pm | 22 ++++++++++++---------- > Koha/Statistic.pm | 16 ---------------- > t/db_dependent/Koha/Statistics.t | 8 ++++---- > 4 files changed, 18 insertions(+), 32 deletions(-) > >diff --git a/C4/Stats.pm b/C4/Stats.pm >index bfd2ad52e2..e13d30dafb 100644 >--- a/C4/Stats.pm >+++ b/C4/Stats.pm >@@ -48,14 +48,14 @@ The functions of this module deals with statistics table of Koha database. > > C4::Stats::UpdateStats($params); > >- This is a (legacy) alias for Koha::Statistic->insert($params). >+ This is a (legacy) alias for Koha::Statistic->new($params)->store. > Please see Koha::Statistic module. > > =cut > > sub UpdateStats { > my $params = shift; >- Koha::Statistic->insert($params); >+ Koha::Statistic->new($params)->store; > } > > 1; >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 32310b144c..4d84ab0981 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -231,16 +231,18 @@ sub store { > > sub _add_statistic { > my ( $self, $type ) = @_; >- C4::Stats::UpdateStats({ >- type => $type, >- branch => C4::Context->userenv ? C4::Context->userenv->{branch} : undef, >- borrowernumber => undef, >- categorycode => undef, >- itemnumber => $self->itemnumber, >- ccode => $self->ccode, >- itemtype => $self->effective_itemtype, >- location => $self->location, >- }); >+ C4::Stats::UpdateStats( >+ { >+ borrowernumber => undef, >+ branch => C4::Context->userenv ? C4::Context->userenv->{branch} : undef, >+ categorycode => undef, >+ ccode => $self->ccode, >+ itemnumber => $self->itemnumber, >+ itemtype => $self->effective_itemtype, >+ location => $self->location, >+ type => $type, >+ } >+ ); > } > > =head3 delete >diff --git a/Koha/Statistic.pm b/Koha/Statistic.pm >index 1a0f03834d..c3deb71b2a 100644 >--- a/Koha/Statistic.pm >+++ b/Koha/Statistic.pm >@@ -129,22 +129,6 @@ sub store { > return $self; > } > >-=head3 insert >- >- Koha::Statistic->insert( $params ); >- >- This is a shorthand for ->new($params)->store. >- It is the new equivalent for the legacy C4::Stats::UpdateStats call. >- >-=cut >- >-sub insert { >- my ( $class, $params ) = @_; >- my $statistic = $class->new($params) or return; >- $statistic->store; >- return $statistic; >-} >- > =head3 item > > my $item = $statistic->item; >diff --git a/t/db_dependent/Koha/Statistics.t b/t/db_dependent/Koha/Statistics.t >index d41de56cd5..30b6e571cf 100755 >--- a/t/db_dependent/Koha/Statistics.t >+++ b/t/db_dependent/Koha/Statistics.t >@@ -52,7 +52,7 @@ subtest 'Basic Koha object tests' => sub { > my $item = $builder->build_sample_item; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > >- Koha::Statistic->insert( >+ Koha::Statistic->new( > { > type => 'issue', > branch => $library->branchcode, >@@ -63,7 +63,7 @@ subtest 'Basic Koha object tests' => sub { > ccode => $item->ccode, > interface => C4::Context->interface, > } >- ); >+ )->store; > > my $stat = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next; > is( $stat->borrowernumber, $patron->borrowernumber, 'Patron is there' ); >@@ -107,7 +107,7 @@ subtest 'Test exceptions in ->new' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'Test ->insert (fka UpdateStats)' => sub { >+subtest 'Test new->store (fka UpdateStats)' => sub { > plan tests => 15; > $schema->storage->txn_begin; > >@@ -154,7 +154,7 @@ subtest 'Test ->insert (fka UpdateStats)' => sub { > > sub insert_and_fetch { > my $params = shift; >- my $statistic = Koha::Statistic->insert($params); >+ my $statistic = Koha::Statistic->new($params)->store; > return Koha::Statistics->search( { borrowernumber => $test_params->{borrowernumber} } )->last; > > # FIXME discard_changes would be nicer, but we dont have a PK (yet) >-- >2.30.2
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 33608
:
150840
|
150841
|
150842
|
150843
|
150844
|
150845
|
150846
|
151051
|
151052
|
151053
|
151054
|
151055
|
151056
|
151057
|
151913
|
151915
|
151916
|
151917
|
151918
|
151919
|
151920
|
151921
|
151922
|
153653
|
153654
|
153655
|
153656
|
153657
|
153658
|
153659
|
153660
|
153661
|
153698
|
153699
|
153700
|
153701
|
153702
|
153703
|
153704
|
153705
|
153706
|
153707
|
153708
|
153709
|
153710
|
153711
|
153712
|
153713
|
153765
|
157440
|
157441
|
157442
|
157443
|
157444
|
157445
|
157446
|
157447
|
157448
| 157449