|
Lines 143-172
sub get_descriptions_by_koha_field {
Link Here
|
| 143 |
|
143 |
|
| 144 |
sub get_description_by_category_and_authorised_value { |
144 |
sub get_description_by_category_and_authorised_value { |
| 145 |
my ( $self, $params ) = @_; |
145 |
my ( $self, $params ) = @_; |
| 146 |
return unless defined $params->{category} && defined $params->{authorised_value}; |
146 |
return unless defined $params->{category} and defined $params->{authorised_value}; |
| 147 |
|
147 |
|
| 148 |
my $category = $params->{category}; |
148 |
my $category = $params->{category}; |
| 149 |
my $value = $params->{authorised_value}; |
149 |
my $value = $params->{authorised_value}; |
| 150 |
|
150 |
|
| 151 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
151 |
my $cache = Koha::Caches->get_instance(); |
| 152 |
my $cache_key = "AV_description_by_category_and_authorised_value:$category:$value"; |
152 |
my $cache_key = "AV_descriptions:$category"; |
| 153 |
my $description = $memory_cache->get_from_cache($cache_key); |
153 |
my $descriptions = $cache->get_from_cache($cache_key, { unsafe => 1 }); |
| 154 |
|
154 |
|
| 155 |
unless (defined $description) { |
155 |
unless (defined $descriptions) { |
| 156 |
my $av = $self->search( |
156 |
$descriptions = { |
| 157 |
{ |
157 |
map { |
| 158 |
category => $category, |
158 |
$_->authorised_value => { |
| 159 |
authorised_value => $value |
159 |
lib => $_->lib, |
| 160 |
} |
160 |
opac_description => $_->opac_description |
| 161 |
)->next; |
161 |
} |
| 162 |
$description = defined $av ? { |
162 |
} $self->search( |
| 163 |
lib => $av->lib, |
163 |
{ |
| 164 |
opac_description => $av->opac_description |
164 |
category => $category |
| 165 |
} : {}; |
165 |
} |
| 166 |
$memory_cache->set_in_cache( $cache_key, $description ); |
166 |
)->as_list |
|
|
167 |
}; |
| 168 |
$cache->set_in_cache($cache_key, $descriptions); |
| 167 |
} |
169 |
} |
| 168 |
|
170 |
return defined $descriptions->{$value} ? $descriptions->{$value} : {}; |
| 169 |
return $description; |
|
|
| 170 |
} |
171 |
} |
| 171 |
|
172 |
|
| 172 |
=head3 get_descriptions_by_marc_field |
173 |
=head3 get_descriptions_by_marc_field |
| 173 |
- |
|
|