Bug 24467 - *_count methods should be avoided
Summary: *_count methods should be avoided
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Josef Moravec
URL:
Keywords:
Depends on: 24430 24435 24448 24528
Blocks: 20212
  Show dependency treegraph
 
Reported: 2020-01-21 14:13 UTC by Jonathan Druart
Modified: 2020-11-30 21:44 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Circulation function:


Attachments
Bug 24467: Remove _count methods (4.55 KB, patch)
2020-01-22 16:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24467: Remove _count methods introduced for API use (8.05 KB, patch)
2020-01-31 04:49 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 24467: Remove _count methods introduced for API use (8.10 KB, patch)
2020-01-31 06:42 UTC, David Nind
Details | Diff | Splinter Review
Bug 24467: Remove _count methods introduced for API use (8.15 KB, patch)
2020-01-31 09:51 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 24467: (QA follow-up) Fix POD in Koha::Biblio (687 bytes, patch)
2020-01-31 09:51 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 24467: (QA follow-up) Clarify tests wording for ->count methods (1.53 KB, patch)
2020-01-31 09:51 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 (tcohen) 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 (tcohen) 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 (tcohen) 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 (ashimema) 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