Koha-clms/Koha
Tomas Cohen Arazi 39a2763109
Bug 31051: (QA follow-up) Use a single query and avoid duplicated sums
This patch makes the `get_savings` method use a single query to
calculate the sum of the replacement prices. This way we save one query
per item and just rely on the DB features.

It has a side effect: we are not summing items twice.

Added tests for the 'itenumber is null' pathological but common use
case (specially in old_issues), as mentioned by Lucas. Handling for this
is added (grep filtering out undefined ones) and also in the return, for
the empty case, with // 0.

To test:
1. Apply this patch
2. Run:
   qa -c 6 --run-tests
=> SUCCESS: All good
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-02-22 10:03:36 -03:00
..
Account Bug 29021: (QA follow-up) Fix for new parameter, add unit test 2023-01-30 10:39:14 -03:00
Acquisition Bug 32417: Allow NULL in biblionumber in $order->store 2022-12-13 09:14:13 -03:00
App
…
ArticleRequest
…
Auth Bug 31378: (QA follow-up) Defer store until JSON fields are populated 2022-11-18 12:29:55 -03:00
Authority
…
BackgroundJob Bug 32019: Add option to mark items returned via batch modification 2023-02-20 09:54:20 -03:00
Biblio Bug 31889: (follow-up) Correct item order 2022-11-07 07:53:34 -03:00
BiblioUtils Bug 29697: Use flag embed_items 2022-07-22 15:24:11 -03:00
Cache Bug 29623: (QA follow-up) Add POD to Koha::Cache::Lite 2022-06-14 08:26:59 -03:00
Cash Bug 27779: Group payouts by type of debit they're applied against 2022-08-08 13:37:25 -03:00
Charges
…
Checkouts Bug 28854: Improve lost details display for bundle items 2022-07-13 10:35:36 -03:00
Club
…
CodeList/Unimarc Bug 30941: (QA follow-up) Only export what is needed 2022-08-19 11:00:42 -03:00
Config
…
Course
…
Database Bug 32292: Tidy and sort keys 2023-01-31 10:49:36 -03:00
ERM Bug 32030: Fix perlcritic errors 2022-11-09 09:48:26 -03:00
Edifact
…
Exceptions Bug 31080: Prevent bundles from being nested 2022-11-22 16:28:20 -03:00
Exporter Bug 29697: Fix t/db_dependent/Exporter/Record.t 2022-07-25 09:30:35 -03:00
ExternalContent
…
Filter/MARC Revert "Bug 15187: Index 880 in Zebra the same as Elasticsearch" 2022-10-24 14:03:44 -03:00
Hold Bug 22456: Add Koha::Hold::CancellationRequest(s) class(es) 2022-07-29 15:28:20 -03:00
Illrequest Bug 30484: Implement support for ILL request updates 2022-09-23 09:18:45 -03:00
Import Bug 32054: Add get_import_record_matches object method and use it 2023-01-18 15:58:19 +00:00
Indexer
…
Item Bug 24606: (QA follow-up) Add test for encoding/decoding 2022-11-18 12:04:27 -03:00
Library Bug 29922: Make get_search_groups return results sorted by title 2022-07-18 15:11:35 -03:00
List
…
MetadataRecord
…
Middleware
…
Misc
…
Notice
…
Number
…
OAI/Server Bug 30921: (QA follow-up) Remove unnecessary if 2022-09-12 16:26:35 -03:00
Object
…
Objects
…
Old Bug 26648: Prevent explosion in notices on missing item 2022-10-12 09:56:43 -03:00
Patron Bug 31095: (QA follow-up) Fix POD 2023-01-31 10:19:42 -03:00
Patrons Bug 31095: Remove GetDebarments from Patron::Import 2023-01-31 10:19:38 -03:00
Plugins Bug 29672: Clear cache of enabled plugins when a plugin's state change 2022-11-03 11:28:16 -03:00
REST Bug 30962: (QA follow-up) Rename attribute and simplify tests 2023-02-03 10:30:13 -03:00
RecordProcessor
…
Result
…
SMS
…
SMTP Bug 27424: Clarify logic 2023-01-31 10:52:49 -03:00
Schema Bug 30642: (follow-up) Change sql and adapt for translations 2023-02-10 11:07:58 -03:00
SearchEngine Bug 17170: Add the ability to create 'saved searches' for use as filters when searching the catalog 2022-10-21 11:15:18 -03:00
Serial
…
Sitemapper
…
Subscription
…
SuggestionEngine Bug 31069: Remove ExplodedTerms dependency on templates 2022-07-18 12:37:35 -03:00
Tags
…
Template/Plugin Bug 32539: Add exception handling to plugin hooks in template plugin 2023-02-09 10:21:27 -03:00
UI Bug 20256: Use new methods 2023-02-02 11:59:26 -03:00
Util Bug 30678: (follow-up) Add oclc_number routine and friends 2022-07-22 14:58:11 -03:00
XSLT Bug 12758: Add new module call in Koha::XSLT::Base 2022-11-09 09:52:25 -03:00
Z3950Responder Bug 24295: Remove GetTransfer from Z3950Responder 2022-08-26 15:42:07 -03:00
pdfformat Bug 31257: (QA follow-up) Fix some typos 2022-10-11 10:44:11 -03:00
Account.pm Bug 31895: (QA follow-up) Rollback change, add comment 2022-11-07 11:16:28 -03:00
ActionLog.pm
…
ActionLogs.pm
…
AdditionalContent.pm
…
AdditionalContents.pm Bug 29144: Add $contents->find_best_match, $library->opac_info 2022-09-16 09:55:19 -03:00
AdditionalField.pm
…
AdditionalFieldValue.pm
…
AdditionalFieldValues.pm
…
AdditionalFields.pm
…
AdvancedEditorMacro.pm
…
AdvancedEditorMacros.pm
…
ApiKey.pm
…
ApiKeys.pm
…
ArticleRequest.pm
…
ArticleRequests.pm
…
AudioAlert.pm
…
AudioAlerts.pm
…
AuthUtils.pm Bug 29744: (QA follow-up) Call psgi_env in OO style 2022-09-22 08:11:58 -03:00
AuthorisedValue.pm
…
AuthorisedValueCategories.pm
…
AuthorisedValueCategory.pm
…
AuthorisedValues.pm
…
Authorities.pm
…
Authority.pm Bug 29897: Remove 'linkage' leftover 2022-08-09 10:58:48 -03:00
BackgroundJob.pm Bug 32561: Prevent worker to run with unecessary modules in memory 2023-01-27 15:15:47 -03:00
BackgroundJobs.pm Bug 31969: Use filter_by_last_update 2022-11-25 09:40:09 -03:00
Biblio.pm Bug 31326: Koha::Biblio->get_components_query fetches too many component parts 2023-01-31 11:03:11 -03:00
BiblioFramework.pm
…
BiblioFrameworks.pm
…
BiblioUtils.pm Bug 29697: Don't crash ES reindex if a record is wrong 2022-07-22 15:24:12 -03:00
Biblioitem.pm
…
Biblioitems.pm
…
Biblios.pm
…
Cache.pm
…
Caches.pm
…
Calendar.pm
…
Checkout.pm Bug 30612: Rename other occurrences 2022-08-01 09:59:05 -03:00
Checkouts.pm
…
CirculationRule.pm
…
CirculationRules.pm Bug 23012: (QA follow-up) Combine method to get both values 2022-10-24 17:43:29 -03:00
Cities.pm
…
City.pm
…
ClassSortRule.pm
…
ClassSortRules.pm
…
ClassSource.pm
…
ClassSources.pm
…
ClassSplitRule.pm
…
ClassSplitRules.pm
…
Club.pm
…
Clubs.pm
…
Config.pm
…
CookieManager.pm Bug 31250: (QA follow-up) The future will be easier 2022-09-12 15:34:11 -03:00
Course.pm
…
Courses.pm
…
CoverImage.pm
…
CoverImages.pm
…
CsvProfile.pm
…
CsvProfiles.pm
…
CurbsidePickup.pm Bug 30650: (QA follow-up) Some higher-level methods usage 2022-07-29 15:38:51 -03:00
CurbsidePickupIssue.pm Bug 30650: Add some useful modules and tests 2022-07-29 14:59:57 -03:00
CurbsidePickupIssues.pm Bug 30650: Add some useful modules and tests 2022-07-29 14:59:57 -03:00
CurbsidePickupOpeningSlot.pm Bug 30650: Add some useful modules and tests 2022-07-29 14:59:57 -03:00
CurbsidePickupOpeningSlots.pm Bug 30650: Add some useful modules and tests 2022-07-29 14:59:57 -03:00
CurbsidePickupPolicies.pm Bug 30650: Add some useful modules and tests 2022-07-29 14:59:57 -03:00
CurbsidePickupPolicy.pm Bug 32891: Fix slot selection in last hour 2023-02-21 10:22:28 -03:00
CurbsidePickups.pm Bug 30650: Add filter_by_scheduled_today 2022-07-29 15:00:47 -03:00
Database.pm
…
DateUtils.pm Bug 30717: (QA follow-up) Move to module 2022-05-13 15:41:55 -10:00
Desk.pm
…
Desks.pm
…
EDI.pm Bug 28672: (QA follow-up) Method calls cannot be interpolated directly 2023-02-07 15:39:31 -03:00
Edifact.pm
…
Email.pm
…
Encryption.pm Bug 31053: Add Context module to Koha::Encryption 2022-06-27 11:46:22 -03:00
Exception.pm
…
Exceptions.pm Bug 31378: Add 'parameter' parameter to Koha::Exceptions::MissingParameter 2022-11-08 14:31:15 -03:00
ExternalContent.pm
…
FrameworkPlugin.pm
…
Hold.pm Bug 31894: Extend after_hold_action hook 2022-11-09 10:05:32 -03:00
Holds.pm Bug 32529: Add Koha::Holds->filter_by_found 2023-01-05 09:21:10 -03:00
I18N.pm Bug 30941: Add cataloguing plugins for 146$bcdef (UNIMARC) 2022-08-19 08:55:09 -03:00
Illcomment.pm
…
Illcomments.pm
…
Illrequest.pm Bug 22321: Fix store() crash when modifying borrowernumber of a new ILL request 2022-10-24 17:33:18 -03:00
Illrequestattribute.pm
…
Illrequestattributes.pm
…
Illrequests.pm
…
ImportBatch.pm
…
ImportBatchProfile.pm
…
ImportBatchProfiles.pm
…
ImportBatches.pm
…
Item.pm Bug 20256: Use new methods 2023-02-02 11:59:26 -03:00
ItemType.pm
…
ItemTypes.pm
…
Items.pm Bug 32019: (follow-up) Fix terminology and styling 2023-02-20 09:54:20 -03:00
KeyboardShortcut.pm
…
KeyboardShortcuts.pm
…
Libraries.pm
…
Library.pm Bug 29144: Add $contents->find_best_match, $library->opac_info 2022-09-16 09:55:19 -03:00
Linktracker.pm
…
Localization.pm
…
Localizations.pm
…
Logger.pm Bug 22678: (follow-up) Array ref expected in context key 2022-10-24 14:37:05 -03:00
Manual.pm Bug 31162: (QA follow-up) Use new WRAPPPERs and fix help link 2022-10-18 10:21:03 -03:00
MarcOverlayRule.pm
…
MarcOverlayRules.pm
…
MarcSubfieldStructure.pm
…
MarcSubfieldStructures.pm
…
MessageAttribute.pm
…
MessageAttributes.pm
…
MetaSearcher.pm Bug 30813: (QA follow-up) Adjust three use statements 2022-06-08 11:40:32 -03:00
MetadataIterator.pm
…
MetadataRecord.pm Bug 30813: (follow-up) Correct C4::Breeding call 2022-06-08 11:40:31 -03:00
MoreUtils.pm
…
OAuth.pm
…
OAuthAccessToken.pm
…
OAuthAccessTokens.pm
…
Object.pm Bug 26635: (follow-up) Rename av_expand to strings 2022-11-09 14:01:02 -03:00
Objects.pm
…
Patron.pm Bug 31051: (QA follow-up) Use a single query and avoid duplicated sums 2023-02-22 10:03:36 -03:00
Patrons.pm Bug 31937: Fix Patrons::search_unsubscribed - sharpen condition 2022-11-17 13:41:24 -03:00
Plugins.pm Bug 29672: (QA follow-up) Add POD 2022-11-03 11:29:43 -03:00
ProblemReport.pm
…
ProblemReports.pm
…
PseudonymizedTransaction.pm
…
PseudonymizedTransactions.pm
…
Quote.pm
…
Quotes.pm
…
RDF.pm
…
Rating.pm
…
Ratings.pm
…
Recall.pm Bug 30823: Filling recalls uses 'FILL' action in action logs 2022-07-01 16:09:13 -03:00
Recalls.pm Bug 31896: New after_recall_action hook 2022-11-09 14:34:41 -03:00
RecordProcessor.pm
…
Report.pm Bug 30718: Use flatpickr's altInput 2022-08-19 08:26:31 -03:00
Reports.pm
…
Review.pm
…
Reviews.pm
…
Schema.pm
…
Script.pm
…
SearchEngine.pm
…
SearchField.pm
…
SearchFields.pm
…
SearchFilter.pm Bug 17170: (QA follow-up) Spec cleanup 2022-10-21 11:15:22 -03:00
SearchFilters.pm Bug 17170: DB Updates 2022-10-21 11:15:13 -03:00
SearchMarcMap.pm
…
SearchMarcMaps.pm
…
Serial.pm
…
Serials.pm
…
SharedContent.pm
…
SimpleMARC.pm Bug 31644: Check if subfield defined, not for truth 2022-10-24 11:53:18 -03:00
Sitemapper.pm
…
Statistic.pm
…
Statistics.pm
…
StockRotationItem.pm
…
StockRotationItems.pm
…
StockRotationRota.pm
…
StockRotationRotas.pm
…
StockRotationStage.pm
…
StockRotationStages.pm
…
Subscription.pm
…
Subscriptions.pm
…
Suggestion.pm Bug 31374: (follow-up) change private note to staff_note and reorder columns 2022-09-07 13:32:51 -07:00
SuggestionEngine.pm
…
Suggestions.pm Bug 30663: Add Koha::Suggestions helper methods 2022-05-05 10:26:41 -03:00
Tag.pm
…
Tags.pm
…
Token.pm Bug 27849: (follow-up) Add test 2022-08-01 09:53:35 -03:00
TrackedLink.pm
…
TrackedLinks.pm
…
UploadedFile.pm
…
UploadedFiles.pm
…
Uploader.pm
…
Virtualshelf.pm Bug 29955: Fix method import issues 2022-08-22 13:06:18 -03:00
Virtualshelfcontent.pm
…
Virtualshelfcontents.pm
…
Virtualshelfshare.pm Bug 25498: (QA follow-up) Rename virtualshelfshare->patron 2022-07-19 11:25:26 -03:00
Virtualshelfshares.pm
…
Virtualshelves.pm Bug 31288: (QA follow-up) Check userenv in disown_or_delete 2022-08-03 11:44:07 -03:00
Z3950Responder.pm
…
Z3950Server.pm
…
Z3950Servers.pm
…