Browse Source

EntryStore::get_sub_entries(): alphabetically sort returned entries

This was particularly noticeable on large tag listings.
main
Brennen Bearnes 1 year ago
parent
commit
11aa204414
4 changed files with 11 additions and 5 deletions
  1. +4
    -0
      Changes
  2. +1
    -1
      lib/App/WRT.pm
  3. +1
    -1
      lib/App/WRT/EntryStore.pm
  4. +5
    -3
      t/wrt_entrystore.t

+ 4
- 0
Changes View File

@ -1,5 +1,9 @@
Revision history for App::WRT
v7.1.2 2020-07-24
- Alphabetically sort sub-entries
v7.1.1 2020-07-23
- Add a date_published to JSON Feed output


+ 1
- 1
lib/App/WRT.pm View File

@ -16,7 +16,7 @@ package App::WRT;
# without overthinking a bunch of hair-splitting decisions and categories,
# but whatever. I'll try to follow it, roughly.
use version; our $VERSION = version->declare("v7.1.1");
use version; our $VERSION = version->declare("v7.1.2");
use strict;
use warnings;


+ 1
- 1
lib/App/WRT/EntryStore.pm View File

@ -418,7 +418,7 @@ sub get_sub_entries {
# index gets special treatment as the text body of an entry, rather
# than as a sub-entry:
my @subs = grep { m/$SUBENTRY_EXPR/ } $self->children_basenames($entry);
return grep { ! $SUBENTRY_IGNORE{$_} } @subs;
return sort grep { ! $SUBENTRY_IGNORE{$_} } @subs;
# return grep { ! $SUBENTRY_IGNORE{$_} }
# grep { m/$SUBENTRY_EXPR/ }


+ 5
- 3
t/wrt_entrystore.t View File

@ -194,9 +194,11 @@ my $es = App::WRT::EntryStore->new('archives');
) or diag(join ', ', @children_basenames);
my (@sub_entries) = $es->get_sub_entries('icon_test');
ok(
scalar @sub_entries == 2,
'expected 2 sub-entries for icon_test'
my (@expected_sub_entries) = ('dir', 'textfile');
is_deeply(
\@sub_entries,
\@expected_sub_entries,
'expected 2 alphabetically sorted sub-entries for icon_test'
) or diag(join ', ', @sub_entries);
# checking whether entries are directories, flatfiles, etc.


Loading…
Cancel
Save