From 4b7433f44317fcd0f33f157f0effe752a0c5ac6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 22 Jul 2010 14:00:20 +0200 Subject: [PATCH] CVar->get_configs cached jetzt so, wie es io.pl eh schon tut. --- SL/CVar.pm | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/SL/CVar.pm b/SL/CVar.pm index 8ecda7460..19f1e5f3d 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -25,25 +25,31 @@ sub get_configs { push @values, $params{module}; } - my $query = qq|SELECT * FROM custom_variable_configs $where ORDER BY sortkey|; + my $query = <{CVAR_CONFIGS}->{$params{module}}) { + my $configs = selectall_hashref_query($form, $dbh, $query, @values); - foreach my $config (@{ $configs }) { - if ($config->{type} eq 'select') { - $config->{OPTIONS} = [ map { { 'value' => $_ } } split(m/\#\#/, $config->{options}) ]; + foreach my $config (@{ $configs }) { + if ($config->{type} eq 'select') { + $config->{OPTIONS} = [ map { { 'value' => $_ } } split(m/\#\#/, $config->{options}) ]; - } elsif ($config->{type} eq 'number') { - $config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i); + } elsif ($config->{type} eq 'number') { + $config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i); - } + } - $self->_unpack_flags($config); + $self->_unpack_flags($config); + } + $::form->{CVAR_CONFIGS}->{$params{module}} = $configs; } $main::lxdebug->leave_sub(); - return $configs; + return $::form->{CVAR_CONFIGS}->{$params{module}}; } sub get_config { @@ -191,13 +197,6 @@ sub get_custom_variables { my $trans_id = $params{trans_id} ? 'OR (v.trans_id = ?) ' : ''; - my $q_cfg = - qq|SELECT id, name, description, type, default_value, options, - date_trunc('seconds', localtimestamp) AS current_timestamp, current_date AS current_date - FROM custom_variable_configs - WHERE module = ? - ORDER BY sortkey|; - my $q_var = qq|SELECT text_value, timestamp_value, timestamp_value::date AS date_value, number_value, bool_value FROM custom_variables @@ -205,7 +204,7 @@ sub get_custom_variables { $q_var .= qq| AND (sub_module = ?)| if $params{sub_module}; my $h_var = prepare_query($form, $dbh, $q_var); - my $custom_variables = selectall_hashref_query($form, $dbh, $q_cfg, $params{module}); + my $custom_variables = $self->get_configs(module => $params{module}); foreach my $cvar (@{ $custom_variables }) { if ($cvar->{type} eq 'textfield') { -- 2.20.1