Bug 24467

Summary: *_count methods should be avoided
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, agustinmoyano, josef.moravec, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Bug Depends on: 24430, 24435, 24448, 24528    
Bug Blocks: 20212    
Attachments: Bug 24467: Remove _count methods
Bug 24467: Remove _count methods introduced for API use
Bug 24467: Remove _count methods introduced for API use
Bug 24467: Remove _count methods introduced for API use
Bug 24467: (QA follow-up) Fix POD in Koha::Biblio
Bug 24467: (QA follow-up) Clarify tests wording for ->count methods

Description Jonathan Druart 2020-01-21 14:13:25 UTC
Several new methods have been added recently to retrieve the number of elements returned (items_count, subscriptions_count, etc.)
We should find a way to avoid that, as the callers can call ->count easily.
Comment 1 Tomás Cohen Arazi 2020-01-21 14:32:07 UTC
Removing the introduced *_count methods will be a follow-up for this new feature if that's ok with you, Jonathan. I mean part of this bug.
Comment 2 Jonathan Druart 2020-01-22 16:21:07 UTC
Created attachment 97746 [details] [review]
Bug 24467: Remove _count methods

Add a trick to guess what we need to call.

Note that it does not work, do not know why. Tests are missing to make
sure everything is ok.
Comment 3 Jonathan Druart 2020-01-22 16:21:26 UTC
This is what I had in mind.
Comment 4 Tomás Cohen Arazi 2020-01-22 18:04:54 UTC
(In reply to Jonathan Druart from comment #3)
> This is what I had in mind.

Nice, I would prefer the + separator. And was waiting for bug 24356 and the work Agustin is doing for sorting and filtering on related tables.
Comment 5 Tomás Cohen Arazi 2020-01-31 04:49:04 UTC
Created attachment 98198 [details] [review]
Bug 24467: Remove _count methods introduced for API use

This patch removes some methods that were introduced for API usage in
the first iteration of the object embedding development effort.

Those methods were obsoleted by bug 24528, which introduces a smarter
way for Koha::Object->to_api to embed *_count attributes on the output
structure based on the relationships and a call to ->count.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass
3. Sign off :-D
Comment 6 David Nind 2020-01-31 06:42:14 UTC
Created attachment 98202 [details] [review]
Bug 24467: Remove _count methods introduced for API use

This patch removes some methods that were introduced for API usage in
the first iteration of the object embedding development effort.

Those methods were obsoleted by bug 24528, which introduces a smarter
way for Koha::Object->to_api to embed *_count attributes on the output
structure based on the relationships and a call to ->count.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Josef Moravec 2020-01-31 09:51:24 UTC
Created attachment 98218 [details] [review]
Bug 24467: Remove _count methods introduced for API use

This patch removes some methods that were introduced for API usage in
the first iteration of the object embedding development effort.

Those methods were obsoleted by bug 24528, which introduces a smarter
way for Koha::Object->to_api to embed *_count attributes on the output
structure based on the relationships and a call to ->count.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 8 Josef Moravec 2020-01-31 09:51:32 UTC
Created attachment 98219 [details] [review]
Bug 24467: (QA follow-up) Fix POD in Koha::Biblio

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 9 Josef Moravec 2020-01-31 09:51:38 UTC
Created attachment 98220 [details] [review]
Bug 24467: (QA follow-up) Clarify tests wording for ->count methods

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 10 Martin Renvoize 2020-01-31 13:51:25 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 11 Joy Nelson 2020-02-10 23:48:47 UTC
Enhancement not backported to 19.11.x