File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -857,4 +857,48 @@ sub prefix {
857857 );
858858}
859859
860+ =head2 history
861+
862+ Find the history of a given module/documentation.
863+
864+ =cut
865+
866+ sub history {
867+ my ($self , $type , $module , @path ) = @_ ;
868+ my $search = $type eq " module"
869+ ? $self -> filter({
870+ nested => {
871+ path => " module" ,
872+ query => {
873+ constant_score => {
874+ filter => { and => [
875+ { term =>
876+ { " module.authorized" => \1 }
877+ },
878+ { term => { " module.indexed" => \1 }
879+ },
880+ { term => { " module.name" => $module }
881+ },
882+ ] }
883+ }
884+ }
885+ }
886+ })
887+ : $type eq " file"
888+ ? $self -> filter({
889+ and => [
890+ { term => { " file.path" => join (" /" , @path ) } },
891+ { term => { " file.distribution" => $module } },
892+ ]
893+ })
894+ : $self -> filter({
895+ and => [
896+ { term => { " file.documentation" => $module } },
897+ { term => { " file.indexed" => \1 } },
898+ { term => { " file.authorized" => \1 } },
899+ ]
900+ });
901+ return $search -> sort ([{ " file.date" => " desc" }]);
902+ }
903+
860904__PACKAGE__ -> meta-> make_immutable;
Original file line number Diff line number Diff line change @@ -63,4 +63,14 @@ $signature = $idx->type('file')->filter(
6363)-> first;
6464ok(!$signature , ' SIGNATURE is not documentation' );
6565
66+ {
67+ my $files = $idx -> type(" file" );
68+ my $module = $files -> history(module => " Moose" )-> raw-> all;
69+ my $file = $files -> history(file => " Moose" , " lib/Moose.pm" )-> raw-> all;
70+ is_deeply($module -> {hits }, $file -> {hits }, " history of Moose and lib/Moose.pm match" );
71+ is($module -> {hits }-> {total }, 2, " two hits" );
72+ my $pod = $files -> history(documentation => " Moose::FAQ" )-> raw-> all;
73+ is($pod -> {hits }-> {total }, 1, " one hit" );
74+ }
75+
6676done_testing;
You can’t perform that action at this time.
0 commit comments