@@ -17,7 +17,13 @@ has query_file => (
17
17
isa => ' MetaCPAN::Query::File' ,
18
18
lazy => 1,
19
19
builder => ' _build_query_file' ,
20
- handles => [qw< dir interesting_files > ],
20
+ handles => [
21
+ qw(
22
+ dir
23
+ interesting_files
24
+ files_by_category
25
+ )
26
+ ],
21
27
);
22
28
23
29
sub _build_query_file {
@@ -654,75 +660,10 @@ sub autocomplete_suggester {
654
660
655
661
sub find_changes_files {
656
662
my ( $self , $author , $release ) = @_ ;
657
-
658
- # find the most likely file
659
- # TODO: should we do this when the release is indexed
660
- # and store the result as { 'changes_file' => $name }
661
-
662
- my @candidates = qw(
663
- CHANGELOG
664
- ChangeLog
665
- Changelog
666
- ChangeLog.pm
667
- changelog.pm
668
- ChangeLog.pod
669
- CHANGES
670
- Changes
671
- CHANGES.md
672
- CHANGES.markdown
673
- CHANGES.pm
674
- Changes.pm
675
- CHANGES.pod
676
- Changes.pod
677
- NEWS
678
- ) ;
679
-
680
- # use $c->model b/c we can't let any filters apply here
681
- my $file = $self -> raw-> filter(
682
- {
683
- and => [
684
- { term => { release => $release } },
685
- { term => { author => $author } },
686
- {
687
- or => [
688
-
689
- # if it's a perl release, get perldelta
690
- {
691
- and => [
692
- { term => { distribution => ' perl' } },
693
- {
694
- term => {
695
- ' name' => ' perldelta.pod'
696
- }
697
- },
698
- ]
699
- },
700
-
701
- # otherwise look for one of these candidates in the root
702
- {
703
- and => [
704
- { term => { level => 0 } },
705
- { term => { directory => 0 } },
706
- {
707
- or => [
708
- map { { term => { ' name' => $_ } } }
709
- @candidates
710
- ]
711
- }
712
- ]
713
- }
714
- ],
715
- }
716
- ]
717
- }
718
- )-> size(1)
719
-
720
- # HACK: Sort by level/desc to put pod/perldeta.pod first (if found)
721
- # otherwise sort root files by name and select the first.
722
- -> sort ( [ { level => ' desc' }, { name => ' asc' } ] )-> first;
723
-
724
- return unless is_hashref($file );
725
- return $file -> {_source };
663
+ my $result = $self -> files_by_category( $author , $release , [' changelog' ],
664
+ { fields => \1 } );
665
+ my ($file ) = @{ $result -> {categories }{changelog } || [] };
666
+ return $file ;
726
667
}
727
668
728
669
__PACKAGE__ -> meta-> make_immutable;
0 commit comments