From 2548378e55d652758e60d5b5d455f2bcab642cd9 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 14 May 2024 18:13:38 +0200 Subject: [PATCH] fix parsing of rating end points The fake rating search end points need the Deserialize ActionClass to parse their body. Also, MetaCPAN::Client has a bug that prevents it from properly using its testing user agent, so just give the results for normal MC::C UAs. --- lib/MetaCPAN/Server/Controller/Rating.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/MetaCPAN/Server/Controller/Rating.pm b/lib/MetaCPAN/Server/Controller/Rating.pm index 9511497be..2bd9e474e 100644 --- a/lib/MetaCPAN/Server/Controller/Rating.pm +++ b/lib/MetaCPAN/Server/Controller/Rating.pm @@ -28,17 +28,15 @@ sub _mapping : Path('_mapping') : Args(0) { $c->detach('/not_found'); } -sub find : Path('_search') : Args(0) { +sub find : Path('_search') : Args(0) : ActionClass('~Deserialize') { my ( $self, $c, $scroll ) = @_; my @hits; # fake results for MetaCPAN::Client so it doesn't fail its tests - if ( ( $c->req->user_agent // '' ) - =~ m{^MetaCPAN::Client-testing/([0-9.]+)} ) - { + if ( ( $c->req->user_agent // '' ) =~ m{^MetaCPAN::Client/([0-9.]+)} ) { if ( $1 <= 2.031001 ) { - my $query = $c->read_param('query'); + my $query = $c->params->{'query'}; if ( $query && $query->[0] && $query->[0]{term} @@ -72,7 +70,7 @@ sub find : Path('_search') : Args(0) { } ); } -sub all : Path('') : Args(0) { +sub all : Path('') : Args(0) : ActionClass('~Deserialize') { my ( $self, $c ) = @_; $c->forward('find'); }