From 0682dd7ebd3f16a8b7cf282df5c8343d6fa10068 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 19 Jun 2014 15:11:59 +0200 Subject: [PATCH] SL::DB::Part: Cachen von Objekten gefixt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Über Steuerzonen erhaltene Informationen müssen pro Part-ID gecachet werden, weil diese natürlich Artikel-spezifisch sind. --- SL/DB/Part.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index a0f9c1034..1380c4d2b 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -146,17 +146,18 @@ sub get_taxkey { my $taxzone = $params{ defined($params{taxzone}) ? 'taxzone' : 'taxzone_id' } * 1; my $tk_info = $::request->cache('get_taxkey'); - $tk_info->{$taxzone} ||= { }; - $tk_info->{$taxzone}->{$is_sales} ||= { }; + $tk_info->{$self->id} //= {}; + $tk_info->{$self->id}->{$taxzone} //= { }; + my $cache = $tk_info->{$self->id}->{$taxzone}->{$is_sales} //= { }; - if (!exists $tk_info->{$taxzone}->{$is_sales}->{$date}) { - $tk_info->{$taxzone}->{$is_sales}->{$date} = + if (!exists $cache->{$date}) { + $cache->{$date} = $self->get_chart(type => $is_sales ? 'income' : 'expense', taxzone => $taxzone) ->load ->get_active_taxkey($date); } - return $tk_info->{$taxzone}->{$is_sales}->{$date}; + return $cache->{$date}; } sub get_chart { @@ -165,7 +166,7 @@ sub get_chart { my $type = (any { $_ eq $params{type} } qw(income expense inventory)) ? $params{type} : croak("Invalid 'type' parameter '$params{type}'"); my $taxzone = $params{ defined($params{taxzone}) ? 'taxzone' : 'taxzone_id' } * 1; - my $charts = $::request->cache('get_chart_id/by_taxzones'); + my $charts = $::request->cache('get_chart_id/by_part_id_and_taxzone')->{$self->id} //= {}; my $all_charts = $::request->cache('get_chart_id/by_id'); $charts->{$taxzone} ||= { }; -- 2.20.1