Bugzilla – Attachment 75259 Details for
Bug 19792
Reduce number of SQL calls in GetBudgetHierarchy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19792: (QA follow-up) Move anonymous sub out of GetHierarchy
Bug-19792-QA-follow-up-Move-anonymous-sub-out-of-G.patch (text/plain), 3.20 KB, created by
Marcel de Rooy
on 2018-05-11 07:58:07 UTC
(
hide
)
Description:
Bug 19792: (QA follow-up) Move anonymous sub out of GetHierarchy
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-05-11 07:58:07 UTC
Size:
3.20 KB
patch
obsolete
>From b5b750640a7c6cf81057eed6f315f90a4cb3c5e5 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 27 Dec 2017 17:04:36 +0100 >Subject: [PATCH] Bug 19792: (QA follow-up) Move anonymous sub out of > GetHierarchy >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Budgets.t. >Without both patches, running the test is slower than with only the first >or both patches. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Jon Knight <J.P.Knight@lboro.ac.uk> >--- > C4/Budgets.pm | 43 +++++++++++++++++++++---------------------- > 1 file changed, 21 insertions(+), 22 deletions(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 6d2718a..c59d86a 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -573,35 +573,34 @@ sub GetBudgetHierarchy { > GROUP BY shipmentcost_budgetid > |, 'budget_id'); > >- my $recursiveAdd; >- $recursiveAdd = sub { >- my ($budget, $parent) = @_; > >- foreach my $child (@{$budget->{children}}){ >- $recursiveAdd->($child, $budget); >+ foreach my $budget (@sort) { >+ if ($budget->{budget_parent_id} == undef) { >+ _recursiveAdd( $budget, undef, $hr_budget_spent, $hr_budget_spent_shipment, $hr_budget_ordered, $hr_budget_ordered_shipment ); > } >+ } >+ return \@sort; >+} > >- $budget->{budget_spent} += $hr_budget_spent->{$budget->{budget_id}}->{budget_spent}; >- $budget->{budget_spent} += $hr_budget_spent_shipment->{$budget->{budget_id}}->{shipmentcost}; >- $budget->{budget_ordered} += $hr_budget_ordered->{$budget->{budget_id}}->{budget_ordered}; >- $budget->{budget_ordered} += $hr_budget_ordered_shipment->{$budget->{budget_id}}->{shipmentcost}; >+sub _recursiveAdd { >+ my ($budget, $parent, $hr_budget_spent, $hr_budget_spent_shipment, $hr_budget_ordered, $hr_budget_ordered_shipment ) = @_; > >- $budget->{total_spent} += $budget->{budget_spent}; >- $budget->{total_ordered} += $budget->{budget_ordered}; >+ foreach my $child (@{$budget->{children}}){ >+ _recursiveAdd($child, $budget, $hr_budget_spent, $hr_budget_spent_shipment, $hr_budget_ordered, $hr_budget_ordered_shipment ); >+ } > >- if ($parent) { >- $parent->{total_spent} += $budget->{total_spent}; >- $parent->{total_ordered} += $budget->{total_ordered}; >- } >- }; >+ $budget->{budget_spent} += $hr_budget_spent->{$budget->{budget_id}}->{budget_spent}; >+ $budget->{budget_spent} += $hr_budget_spent_shipment->{$budget->{budget_id}}->{shipmentcost}; >+ $budget->{budget_ordered} += $hr_budget_ordered->{$budget->{budget_id}}->{budget_ordered}; >+ $budget->{budget_ordered} += $hr_budget_ordered_shipment->{$budget->{budget_id}}->{shipmentcost}; > >- foreach my $budget (@sort) { >- if ($budget->{budget_parent_id} == undef) { >- $recursiveAdd->($budget); >- } >- } >+ $budget->{total_spent} += $budget->{budget_spent}; >+ $budget->{total_ordered} += $budget->{budget_ordered}; > >- return \@sort; >+ if ($parent) { >+ $parent->{total_spent} += $budget->{total_spent}; >+ $parent->{total_ordered} += $budget->{total_ordered}; >+ } > } > > # Recursive method to add a budget and its chidren to an array >-- >2.1.4
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 19792
:
69702
|
69960
|
70296
|
70297
|
70298
|
70306
|
71989
|
71990
|
71991
|
74983
|
74984
|
74985
|
75258
| 75259 |
75260