rebuild stats link on columns page
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Jun 2010 16:09:41 +0000 (18:09 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Jun 2010 16:09:41 +0000 (18:09 +0200)
lib/MojoFacets/Data.pm
templates/data/columns.html.ep

index dffc48b..bbe311c 100644 (file)
@@ -90,6 +90,8 @@ sub __stats {
 
        my $nr_items = $#{ $_[0] } + 1;
 
+       warn "__stats $nr_items\n";
+
        foreach my $e ( @{ $_[0] } ) {
                foreach my $n ( keys %$e ) {
                        $stats->{$n}->{count}++;
@@ -145,7 +147,8 @@ sub _param_or_session {
 sub stats {
        my $self = shift;
        my $path = $self->_param_or_session('path');
-       $loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
+       warn "stats $path\n";
+       delete $loaded->{$path}->{stats};
        $self->redirect_to( '/data/columns' );
 }
 
@@ -291,6 +294,10 @@ sub _loaded {
                $self->_load_path( $path );
                $self->redirect_to('/data/index')
                        unless defined $loaded->{$path}->{$name};
+               if ( ! defined $loaded->{$path}->{stats} ) {
+                       warn "rebuild stats for $path\n";
+                       $loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
+               }
        }
        return $loaded->{$path}->{$name};
 }
index 23b3171..5ea9dff 100644 (file)
@@ -45,6 +45,8 @@ $(document).ready(function() {
 
 from <input type=text name=path value="<%= session('path') %>" readonly>
 
+<a href="<%= url_for( action => 'stats' ) %>">rebuild stats</a>
+
 </form>
 
 <pre class=debug>