Bugzilla – Attachment 182887 Details for
Bug 39900
Add public REST endpoint for additional_contents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39900: Preparation: Refactor public_query_search_params for reusability
Bug-39900-Preparation-Refactor-publicquerysearchpa.patch (text/plain), 3.04 KB, created by
David Nind
on 2025-06-01 20:07:49 UTC
(
hide
)
Description:
Bug 39900: Preparation: Refactor public_query_search_params for reusability
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-06-01 20:07:49 UTC
Size:
3.04 KB
patch
obsolete
>From 726cff9ec8a3b9f31a562a0b78f5f0843d4740e4 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Wed, 14 May 2025 10:40:01 +0000 >Subject: [PATCH] Bug 39900: Preparation: Refactor public_query_search_params > for reusability > >Ensure no regressions are introduced, run: >prove t/db_dependent/Koha/AdditionalContents.t > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/AdditionalContents.pm | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > >diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm >index a16089e524..ff7bf0b82a 100644 >--- a/Koha/AdditionalContents.pm >+++ b/Koha/AdditionalContents.pm >@@ -38,6 +38,26 @@ Koha::AdditionalContents - Koha Additional content object set class > > =cut > >+=head3 get_public_query_search_params >+ >+ my $public_query_search_params = $self->get_public_query_search_params($params); >+ >+=cut >+ >+sub get_public_query_search_params { >+ my ($params) = @_; >+ >+ my $search_params; >+ $search_params->{'additional_content.id'} = $params->{id} if $params->{id}; >+ $search_params->{location} = $params->{location}; >+ $search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef; >+ $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' } unless $params->{id}; >+ $search_params->{expirationdate} = [ '-or', { '>=' => \'CAST(NOW() AS DATE)' }, undef ] unless $params->{id}; >+ $search_params->{category} = $params->{category} if $params->{category}; >+ >+ return $search_params; >+} >+ > =head3 search_for_display > > my $contents = Koha::AdditionalContents->search_for_display({ >@@ -80,15 +100,9 @@ sub search_for_display { > my $subquery = > qq|(SELECT COUNT(*) FROM additional_contents_localizations WHERE lang='$lang' AND additional_content_id=me.additional_content_id)=0|; > >- my $search_params; >- $search_params->{'additional_content.id'} = $params->{id} if $params->{id}; >- $search_params->{location} = $params->{location}; >- $search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef; >- $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' } unless $params->{id}; >- $search_params->{expirationdate} = [ '-or', { '>=' => \'CAST(NOW() AS DATE)' }, undef ] unless $params->{id}; >- $search_params->{category} = $params->{category} if $params->{category}; >- $search_params->{lang} = 'default' if !$lang || $lang eq 'default'; >- $search_params->{-or} = [ { 'lang' => $lang }, '-and' => [ 'lang', 'default', \$subquery ] ] >+ my $search_params = get_public_query_search_params($params); >+ $search_params->{lang} = 'default' if !$lang || $lang eq 'default'; >+ $search_params->{-or} = [ { 'lang' => $lang }, '-and' => [ 'lang', 'default', \$subquery ] ] > if !$search_params->{lang}; > > my $attribs = { prefetch => 'additional_content', order_by => 'additional_content.number' }; >-- >2.39.5
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 39900
:
182439
|
182440
|
182441
|
182442
|
182443
| 182887 |
182888
|
182889
|
182890
|
182891