Skip to content

Commit 56a1bb0

Browse files
committed
drop support for metacpan_script
We no longer need metacpan_script for anything our code uses, and supporting it complicates our query filtering and interactions with Elasticsearch. We've generally been trying to move away from users interacting via Elasticsearch queries, but if they really need to and need a specific script, they are always welcome to submit a PR to the API adding what they need.
1 parent f67d282 commit 56a1bb0

File tree

2 files changed

+0
-62
lines changed

2 files changed

+0
-62
lines changed

lib/MetaCPAN/Server/QuerySanitizer.pm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ sub _scan_hash_tree {
3737
}
3838
_scan_hash_tree($v) if ref $v;
3939
}
40-
if ( my $mscript = delete $struct->{metacpan_script} ) {
41-
$struct->{script_score} = {
42-
script => {
43-
lang => 'groovy',
44-
file => $mscript
45-
},
46-
};
47-
}
4840
}
4941
elsif ( $ref eq 'ARRAY' ) {
5042
foreach my $item (@$struct) {

t/server/sanitize_query.t

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,6 @@ test_psgi app, sub {
4747
}
4848
);
4949
}
50-
51-
local
52-
$MetaCPAN::Server::QuerySanitizer::metacpan_scripts{test_script_field}
53-
= q{doc['author.pauseid'].value.length() * 2};
54-
55-
test_all_methods(
56-
{
57-
query => { match_all => {} },
58-
script_fields =>
59-
{ pauselen2 => { metacpan_script => 'test_script_field' }, },
60-
filter => { term => { pauseid => 'RWSTAUNER' } },
61-
},
62-
sub {
63-
my ($req) = shift;
64-
65-
my $res = $cb->($req);
66-
is $res->code, 200, $req->method . ' 200 OK'
67-
or diag explain $res;
68-
69-
my $json = decode_json_ok($res);
70-
71-
is_deeply $json->{hits}{hits}->[0]->{fields},
72-
{ pauselen2 => [18] }, 'script_fields via metacpan_script'
73-
or diag explain $json;
74-
},
75-
);
7650
};
7751

7852
sub test_all_methods {
@@ -126,34 +100,6 @@ my %replacements = (
126100
stupid_script_that_doesnt_exist => undef,
127101
);
128102

129-
while ( my ( $mscript, $re ) = each %replacements ) {
130-
my $query = filtered_custom_score_hash( metacpan_script => $mscript );
131-
132-
my $sanitizer = MetaCPAN::Server::QuerySanitizer->new( query => $query, );
133-
134-
my $cleaned = $sanitizer->query;
135-
like_if_defined
136-
delete $cleaned->{query}{filtered}{query}{custom_score}{script},
137-
$re, "$mscript script replaced";
138-
139-
is_deeply $cleaned, filtered_custom_score_hash(),
140-
'metacpan_script removed';
141-
142-
# try another hash structure
143-
$query
144-
= {
145-
foo => { bar => [ { metacpan_script => $mscript, other => 'val' } ] }
146-
};
147-
148-
$cleaned
149-
= MetaCPAN::Server::QuerySanitizer->new( query => $query )->query;
150-
151-
like_if_defined delete $cleaned->{foo}{bar}->[0]->{script},
152-
$re, "$mscript script replaced";
153-
is_deeply $cleaned, { foo => { bar => [ { other => 'val' } ] } },
154-
'any hash structure accepts metacpan_script';
155-
}
156-
157103
hash_key_rejected( script => { script => 'foobar' } );
158104
hash_key_rejected(
159105
script => { tree => { of => 'many', hashes => { script => 'foobar' } } }

0 commit comments

Comments
 (0)