File tree Expand file tree Collapse file tree 3 files changed +26
-16
lines changed Expand file tree Collapse file tree 3 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ has query_release => (
20
20
by_author
21
21
by_author_and_name
22
22
by_author_and_names
23
+ find
23
24
get_contributors
24
25
get_files
25
26
latest_by_author
@@ -42,21 +43,6 @@ sub _build_query_release {
42
43
);
43
44
}
44
45
45
- sub find {
46
- my ( $self , $name ) = @_ ;
47
- my $file = $self -> filter( {
48
- and => [
49
- { term => { distribution => $name } },
50
- { term => { status => ' latest' } }
51
- ]
52
- } )-> sort ( [ { date => ' desc' } ] )-> raw-> first;
53
- return unless $file ;
54
-
55
- my $data = $file -> {_source }
56
- || single_valued_arrayref_to_scalar( $file -> {fields } );
57
- return $data ;
58
- }
59
-
60
46
sub find_github_based {
61
47
shift -> filter( {
62
48
and => [
Original file line number Diff line number Diff line change @@ -1286,5 +1286,29 @@ sub predecessor {
1286
1286
return $release -> {_source };
1287
1287
}
1288
1288
1289
+ sub find {
1290
+ my ( $self , $name ) = @_ ;
1291
+
1292
+ my $res = $self -> es-> search(
1293
+ index => $self -> index_name,
1294
+ type => ' release' ,
1295
+ body => {
1296
+ query => {
1297
+ bool => {
1298
+ must => [
1299
+ { term => { distribution => $name } },
1300
+ { term => { status => ' latest' } },
1301
+ ],
1302
+ },
1303
+ },
1304
+ sort => [ { date => ' desc' } ],
1305
+ size => 1,
1306
+ },
1307
+ );
1308
+ my ($file ) = $res -> {hits }{hits }[0];
1309
+ return undef unless $file ;
1310
+ return $file -> {_source };
1311
+ }
1312
+
1289
1313
__PACKAGE__ -> meta-> make_immutable;
1290
1314
1;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ sub release : Chained('index') : PathPart('release') : Args(1) {
33
33
34
34
my ( $latest , $previous );
35
35
try {
36
- $latest = $c -> model(' CPAN::Release' )-> raw -> find($name );
36
+ $latest = $c -> model(' CPAN::Release' )-> find($name );
37
37
$previous
38
38
= $c -> model(' CPAN::Release' )-> predecessor($name );
39
39
}
You can’t perform that action at this time.
0 commit comments