From 3d2c63f62e809cf0985da5174429bf31cc2724b7 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 19 Oct 2010 17:35:23 +0200 Subject: [PATCH] move invalidation before $out processing This change allows us to write sequences like this: $out->{eprints_id} ||= 700; $update->{eprints_id} = $out->{eprints_id}++; We use $out like global variable, and increment values for all filtered fields --- lib/MojoFacets/Data.pm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index b5decf5..97d442d 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -732,6 +732,18 @@ sub items { __commit_path_code( $path, $i, $code, \$commit_changed ); } + # this might move before $out to recalculate stats on source dataset? + __path_rebuild_stats( $path ); + my $c = { map { $_ => 1 } @columns }; + my @added_columns = sort grep { ! $c->{$_} } keys %$commit_changed; + warn "# added_columns ",dump( @added_columns ); + unshift @columns, @added_columns; + + $loaded->{$path}->{columns} = [ @columns ]; + warn "# new columns ",dump( @columns ); + + __invalidate_path_column( $path, $_ ) foreach keys %$commit_changed; + $self->_save_change({ path => $path, time => $self->param('time') || time(), @@ -798,18 +810,7 @@ sub items { return; # FIXME needed to correctly show columns } - # this might move before $out to recalculate stats on source dataset? - __path_rebuild_stats( $path ); - my $c = { map { $_ => 1 } @columns }; - my @added_columns = sort grep { ! $c->{$_} } keys %$commit_changed; - warn "# added_columns ",dump( @added_columns ); - unshift @columns, @added_columns; - $self->session('columns', [ @columns ]); - $loaded->{$path}->{columns} = [ @columns ]; - warn "# new columns ",dump( @columns ); - - __invalidate_path_column( $path, $_ ) foreach keys %$commit_changed; } my $sorted_items; -- 2.20.1