don't rebuild stats if called from edit
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 7 Jun 2010 12:56:59 +0000 (14:56 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 7 Jun 2010 12:56:59 +0000 (14:56 +0200)
This allow us to rebuild stat just once after a bunch of edits or
running ./script/actions-to-changes

lib/MojoFacets/Data.pm

index d476867..63ddb57 100644 (file)
@@ -255,9 +255,14 @@ sub _loaded {
        $self->redirect_to('/data/index') unless $path;
 
        if ( $loaded->{$path}->{modified} > 1 ) {
        $self->redirect_to('/data/index') unless $path;
 
        if ( $loaded->{$path}->{modified} > 1 ) {
-               warn "rebuild stats for $path forced by modified\n";
-               $loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
-               $loaded->{$path}->{modified} = 1;
+               my $caller = (caller(1))[3];
+               if ( $caller =~ m/::edit/ ) {
+                       warn "rebuild stats for $path ignored caller $caller\n";
+               } else {
+                       warn "rebuild stats for $path FORCED by modified caller $caller\n";
+                       $loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
+                       $loaded->{$path}->{modified} = 1;
+               }
        }
 
        if ( ! defined $loaded->{$path}->{$name} ) {
        }
 
        if ( ! defined $loaded->{$path}->{$name} ) {