X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FMojoFacets%2FChanges.pm;h=9c07764e08f094221678de8c1ff6df3d107a4be5;hb=88f36e93420390b7e3d42a3fdba2fd05abf720c4;hp=3b942538f88af141962f65ac56db3c2a1c582693;hpb=31d07c4ea780f9d87f6b04325a625eb732ed3332;p=MojoFacets.git diff --git a/lib/MojoFacets/Changes.pm b/lib/MojoFacets/Changes.pm index 3b94253..9c07764 100644 --- a/lib/MojoFacets/Changes.pm +++ b/lib/MojoFacets/Changes.pm @@ -10,20 +10,27 @@ use Storable; sub index { my $self = shift; - my $max = $self->param('max') || 10; + my $max = $self->param('max') || 50; + my $action_regex = join('|', $self->param('action_filter')); + warn "# action_regex $action_regex\n"; + + my $actions; my $changes; foreach my $path ( sort { $b cmp $a } glob '/tmp/changes/*' ) { if ( $path =~ m{/((\d+\.\d+)\.data\.(.+))$} ) { - push @$changes, { uid => $1, t => $2, action => $3 }; - last if $#$changes > $max; + my ( $uid, $t, $action ) = ( $1, $2, $3 ); + $actions->{$action}++; + next if $action_regex && $action !~ m/^($action_regex)$/; + push @$changes, { uid => $uid, t => $t, action => $action } + if $#$changes < $max; } else { warn "ignore: $path\n"; } } # Render template "changes/index.html.ep" with message - $self->render(message => 'Latest Changes', changes => $changes ); + $self->render(message => 'Latest Changes', changes => $changes, actions => $actions ); }