Merge branch 'master' into save_change
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 4 Jun 2010 15:01:32 +0000 (17:01 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 4 Jun 2010 15:01:32 +0000 (17:01 +0200)
12 files changed:
lib/MojoFacets.pm
lib/MojoFacets/Changes.pm
lib/MojoFacets/Data.pm
public/mojo_facets.css
script/changes [new file with mode: 0755]
templates/admin.html.ep
templates/changes/edits.html.ep [new file with mode: 0644]
templates/changes/view.html.ep
templates/data/columns.html.ep
templates/data/export.html.ep [new file with mode: 0644]
templates/data/facet.html.ep
templates/data/index.html.ep

index c80e748..e68fde8 100644 (file)
@@ -20,9 +20,17 @@ sub save_tx {
        if ( $parts->[0] eq 'data' ) {
                if ( my $params = $tx->req->params ) {
 
+                       warn "# params ",dump($params);
+
+                       my $time = time();
+                       if ( my $time_travel = $params->param('time') ) {
+                               warn "# time-travel to $time_travel from ", $tx->remote_address;
+                               $time = $time_travel;
+                       }
+
                        my $path = '/tmp/changes/';
                        mkdir $path unless -e $path;
-                       $path .= sprintf '%.4f.%s', time(), join('.', @$parts);
+                       $path .= sprintf '%.4f.%s', $time, join('.', @$parts);
 
                        store $params, $path;
                        warn "$path ", -s $path, " bytes\n";
index 9c07764..1fb2cde 100644 (file)
@@ -6,6 +6,8 @@ use warnings;
 use base 'Mojolicious::Controller';
 
 use Storable;
+use Data::Dump qw(dump);
+use MojoFacets::Data;
 
 sub index {
        my $self = shift;
@@ -40,4 +42,60 @@ sub view {
        $self->render( change => retrieve( "/tmp/changes/$uid" ), uid => $uid );
 }
 
+sub _edit_path {
+       my $self = shift;
+       my $path = $self->param('path') || $self->session('path');
+       $self->app->home->rel_dir('data') . '/' . $path . '.edits';
+}
+
+sub edits {
+       my ( $self ) = @_;
+       my $path = $self->param('path') || $self->session('path');
+       my $commit = $self->param('commit');
+       my ( $items, $unique2id );
+       if ( my $apply_on_path = $self->param('apply_on_path') ) {
+               $items = $MojoFacets::Data::loaded->{$apply_on_path}->{data}->{items};
+               die "no $apply_on_path" unless $items;
+               warn "using $items for $apply_on_path\n";
+       }
+       my $edits;
+       my $stats;
+       my $glob = $self->_edit_path . '/*';
+       foreach my $t ( sort { $b cmp $a } glob $glob ) {
+               my $e = retrieve($t);
+               if ( $items ) {
+                       my ($pk,$id) = %{ $e->{unique} };
+                       if ( ! defined $unique2id->{$pk} ) {
+                               warn "unique2id $pk on ", $#$items + 1 ," items\n";
+                               foreach my $i ( 0 .. $#$items ) {
+                                       $unique2id->{$pk}->{ $items->[$i]->{$pk}->[0] } = $i;
+                               }
+                       }
+                       my $status = 'missing';
+                       if ( my $i = $unique2id->{$pk}->{$id} ) {
+                               $status = 'found';
+                               $items->[$i]->{$pk} = $e->{new} if $commit;
+                       }
+                       $e->{_status} = $status;
+                       $stats->{$status}++;
+               }
+               push @$edits, $e;
+       }
+
+       my @loaded = MojoFacets::Data::__loaded_paths();
+       warn "# loaded paths ",dump @loaded;
+
+       $self->render( edits => $edits, loaded => \@loaded, stats => $stats );
+}
+
+sub edit {
+       my $self = shift;
+
+       if ( my $t = $self->param('remove') ) {
+               unlink $self->_edit_path . '/' . $t;
+       }
+
+       $self->redirect_to('/changes/edits');
+}
+
 1;
index 29c7886..ee0b105 100644 (file)
@@ -12,6 +12,7 @@ use Encode;
 use locale;
 use File::Find;
 use Storable;
+use Time::HiRes qw(time);
 
 our $loaded;
 our $filters;
@@ -23,14 +24,14 @@ sub index {
        die "no data dir $path" unless -d $path;
 
        my @files;
-       my $changes;
+       my $edits;
        find( sub {
                my $file = $File::Find::name;
                if ( -f $file && $file =~ m/\.(js(on)?|txt)$/ ) {
                        $file =~ s/$path\/*//;
                        push @files, $file;
-               } elsif ( -f $file && $file =~ m/([^\/]+)\.changes\/(\d+\.\d+.+)/ ) {
-                       push @{ $changes->{$1} }, $2
+               } elsif ( -f $file && $file =~ m/([^\/]+)\.edits\/(\d+\.\d+.+)/ ) {
+                       push @{ $edits->{$1} }, $2
                } else {
                        warn "IGNORE: $file\n";
                }
@@ -51,7 +52,7 @@ sub index {
                loaded => $loaded,
                filters => $filters,
                dump_path => { map { $_ => $self->_dump_path($_) } @files },
-               changes => $changes,
+               edits => $edits,
        );
 }
 
@@ -67,18 +68,91 @@ sub _save {
        my ( $self, $path ) = @_;
 
        my $dump_path = $self->_dump_path( $path );
+       my $first_load = ! -e $dump_path;
        warn "save loaded to $dump_path";
        my $info = $loaded->{$path};
        store $info, $dump_path;
 
-       # sync timestamp
-       #my $mtime = $loaded->{$path}->{mtime};
-       #utime $mtime, $mtime, $dump_path;
+       if ( $first_load ) {
+               my $mtime = $loaded->{$path}->{mtime};
+               utime $mtime, $mtime, $dump_path;
+               warn "sync time to $path at $mtime\n";
+       }
 
        warn $dump_path, ' ', -s $dump_path, " bytes\n";
        return $dump_path;
 }
 
+
+sub __stats {
+
+       my $stats;
+
+       my $nr_items = $#{ $_[0] } + 1;
+
+       warn "__stats $nr_items\n";
+
+       foreach my $e ( @{ $_[0] } ) {
+               foreach my $n ( keys %$e ) {
+                       $stats->{$n}->{count}++;
+                       my @v;
+                       if ( ref $e->{$n} eq 'ARRAY' ) {
+                               $stats->{$n}->{array} += $#{ $e->{$n} } + 1;
+                               @v = @{ $e->{$n} };
+                       } else {
+                               @v = ( $e->{$n} );
+                       }
+
+                       foreach my $x ( @v ) {
+                               $stats->{$n}->{numeric}++
+                                       if $x =~ m/^[-+]?([0-9]*\.[0-9]+|[0-9]+)$/;
+                               $stats->{$n}->{empty}++
+                                       if length $x == 0; # faster than $x =~ m/^\s*$/;
+                       }
+
+               }
+       }
+
+       foreach my $n ( keys %$stats ) {
+               my $s = $stats->{$n};
+               next unless defined $s->{array};
+               if ( $s->{array} == $s->{count} ) {
+                       delete $s->{array};
+                       if ( $s->{count} == $nr_items ) {
+                               warn "check $n for uniqeness\n";
+                               my $unique;
+                               foreach my $e ( @{ $_[0] } ) {
+                                       if ( ++$unique->{ $e->{$n}->[0] } == 2 ) {
+                                               $unique = 0;
+                                               last;
+                                       }
+                               }
+                               if ( $unique ) {
+                                       $stats->{$n}->{unique} = 1;
+                                       warn "# $n unique ",dump( $unique );
+                               }
+                       }
+               }
+       }
+
+       warn "# __stats ",dump($stats);
+
+       return $stats;
+}
+
+sub _param_or_session {
+       $_[0]->param( $_[1] ) || $_[0]->session( $_[1] )
+}
+
+sub stats {
+       my $self = shift;
+       my $path = $self->_param_or_session('path');
+       warn "stats $path\n";
+       delete $loaded->{$path}->{stats};
+       $self->redirect_to( '/data/columns' );
+}
+
+
 sub _load_path {
        my ( $self, $path ) = @_;
 
@@ -146,34 +220,7 @@ sub _load_path {
                warn "file format unknown $path";
        }
 
-       my $stats;
-
-       foreach my $e ( @{ $data->{items} } ) {
-               foreach my $n ( keys %$e ) {
-                       $stats->{$n}->{count}++;
-                       my @v;
-                       if ( ref $e->{$n} eq 'ARRAY' ) {
-                               $stats->{$n}->{array} += $#{ $e->{$n} } + 1;
-                               @v = @{ $e->{$n} };
-                       } else {
-                               @v = ( $e->{$n} );
-                       }
-
-                       foreach my $x ( @v ) {
-                               $stats->{$n}->{numeric}++
-                                       if $x =~ m/^[-+]?([0-9]*\.[0-9]+|[0-9]+)$/;
-                               $stats->{$n}->{empty}++
-                                       if length $x == 0; # faster than $x =~ m/^\s*$/;
-                       }
-
-               }
-       }
-
-       foreach my $n ( keys %$stats ) {
-               next unless defined $stats->{$n}->{array};
-               delete $stats->{$n}->{array}
-                       if $stats->{$n}->{array} == $stats->{$n}->{count};
-       }
+       my $stats = __stats( $data->{items} );
 
        if ( ! @header ) {
                if ( defined $data->{header} ) {
@@ -190,8 +237,6 @@ sub _load_path {
                grep { defined $stats->{$_}->{count} } keys %$stats
                unless @header;
 
-       warn dump($stats);
-
        my $info = {
                header => [ @header ],
                stats  => $stats,
@@ -219,28 +264,40 @@ sub load {
        $self->session('path' => $path);
        $self->_load_path( $path );
 
+       my $redirect_to = '/data/items';
+
        $self->session( 'header' => $loaded->{$path}->{header} );
        if ( ! defined $loaded->{$path}->{columns} ) {
-               $self->session( 'columns' => $loaded->{$path}->{header} );
-               $self->session( 'order'   => $loaded->{$path}->{header}->[0] );
-               $self->redirect_to( '/data/columns' );
-       } else {
-               $self->session( 'columns' => $loaded->{$path}->{columns} );
-               $self->session( 'order'   => $loaded->{$path}->{columns}->[0] );
-               $self->redirect_to( '/data/items' );
+               my $columns_path = $self->_permanent_path( 'columns' );
+               if ( -e $columns_path ) {
+                       my @columns = map { s/[\r\n]+$//; $_ } read_file $columns_path;
+                       $loaded->{$path}->{columns} = [ @columns ];
+                       warn "# columns_path $columns_path ",dump(@columns);
+               } else {
+                       $loaded->{$path}->{columns} = $loaded->{$path}->{header}
+               }
+
+               $redirect_to = '/data/columns';
        }
+       $self->session( 'columns' => $loaded->{$path}->{columns} );
+       $self->session( 'order'   => $loaded->{$path}->{columns}->[0] );
+       $self->redirect_to( $redirect_to );
 }
 
 
 sub _loaded {
        my ( $self, $name ) = @_;
-       my $path = $self->session('path');
+       my $path = $self->session('path') || $self->param('path');
        $self->redirect_to('/data/index') unless $path;
        if ( ! defined $loaded->{$path}->{$name} ) {
                warn "$path $name isn't loaded\n";
                $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};
 }
@@ -254,16 +311,32 @@ sub _checked {
        return $checked;
 }
 
+sub _permanent_path {
+       my $self = shift;
+       my $path = $self->_param_or_session('path');
+       $self->app->home->rel_dir('data') . '/' . join('.', $path, @_);
+}
+
+sub _export_path {
+       my $self = shift;
+       my $path = $self->_param_or_session('path');
+       my $dir = $self->app->home->rel_dir('public') . '/export/';
+       mkdir $dir unless -e $dir;
+       $dir .= $path;
+       mkdir $dir unless -e $dir;
+       $dir . '/' . join('.', @_);
+}
 
 sub columns {
     my $self = shift;
 
        if ( $self->param('columns') ) {
-               $self->_perm_array('columns');
+               my @columns = $self->_param_array('columns');
+               write_file( $self->_permanent_path( 'columns' ), map { "$_\n" } @columns );
                $self->redirect_to('/data/items');
        }
 
-       my $stats = $self->_loaded( 'stats' ); # || $self->redirect_to( '/data/index' );
+       my $stats = $self->_loaded( 'stats' );
 
        my @columns;
        @columns = grep { defined $stats->{$_}->{count} } @{ $self->session('columns') } if $self->session('columns');
@@ -276,11 +349,11 @@ sub columns {
                message => 'Select columns to display',
                stats => $stats,
                columns => \@columns,
-               checked => $self->_checked( $self->_perm_array('columns') ),
+               checked => $self->_checked( $self->_param_array('columns') ),
        );
 }
 
-sub _perm_array {
+sub _param_array {
     my ($self,$name) = @_;
 
        my @array = $self->param($name);
@@ -300,7 +373,7 @@ sub _perm_array {
        return @array;
 }
 
-sub _perm_scalar {
+sub _param_scalar {
     my ($self,$name,$default) = @_;
 
        my $scalar = $self->param($name);
@@ -328,7 +401,14 @@ sub filter {
        my @vals = $self->param('filter_vals');
 
        $self->_remove_filter( $name );
-       $self->_filter_on_data( $name, @vals ) if @vals;
+       if ( @vals ) {
+               $self->_filter_on_data( $name, @vals );
+               if ( my $permanent = $self->param('_permanent') ) {
+                       my $permanent_path = $self->_export_path( 'filter', $name, $permanent );
+                       write_file $permanent_path, map { "$_\n" } @vals;
+                       warn "permanent filter $permanent_path ", -s $permanent_path;
+               }
+       }
 
        $self->session( 'offset' => 0 );
 
@@ -474,13 +554,13 @@ sub items {
        my $path = $self->session('path');
        $self->redirect_to('/data/index') unless defined $loaded->{ $path };
 
-       my @columns = $self->_perm_array('columns');
+       my @columns = $self->_param_array('columns');
        $self->redirect_to('/data/columns') unless @columns;
-       my $order   = $self->_perm_scalar('order', $columns[0]);
-       my $sort    = $self->_perm_scalar('sort', 'a');
-       my $offset  = $self->_perm_scalar('offset', 0);
-       my $limit   = $self->_perm_scalar('limit', 20);
-       $self->_perm_scalar('show', 'table');
+       my $order   = $self->_param_scalar('order', $columns[0]);
+       my $sort    = $self->_param_scalar('sort', 'a');
+       my $offset  = $self->_param_scalar('offset', 0);
+       my $limit   = $self->_param_scalar('limit', 20);
+       $self->_param_scalar('show', 'table');
 
        # fix offset when changing limit
        $offset = int( $offset / $limit ) * $limit;
@@ -619,7 +699,7 @@ sub facet {
        my $facet;
        my $name = $self->param('name') || die "no name";
 
-       my $all = $self->_perm_scalar('all', 1);
+       my $all = $self->_param_scalar('all', 1);
        my $data = $self->_loaded('data');
 
        my $filters = $self->_current_filters;
@@ -709,7 +789,28 @@ sub edit {
                if ( $old ne $new
                        && ! ( $old eq 'undef' && length($new_content) == 0 ) # new value empty, previous undef
                ) {
-                       warn "# update $path $i $old -> $new\n";
+                       my $edit = {
+                               path => $path,
+                               column => $name,
+                               pos => $i,
+                               old => $loaded->{$path}->{data}->{items}->[$i]->{$name},
+                               new => $v,
+                               time => $self->param('time') || time(),
+                               user => $self->param('user') || $ENV{'LOGNAME'},
+                               unique => {
+                                       map { $_ => $loaded->{$path}->{data}->{items}->[$i]->{$_}->[0] }
+                                       grep { defined $loaded->{$path}->{stats}->{$_}->{unique} }
+                                       keys %{ $loaded->{$path}->{stats} }
+                               },
+                       };
+                       my $edit_path = $self->_permanent_path( 'edits' );
+                       mkdir $edit_path unless -d $edit_path;
+                       $edit_path .= '/' . $edit->{time};
+                       store $edit, $edit_path;
+                       utime $edit->{time}, $edit->{time}, $edit_path;
+                       warn "# $edit_path ", dump($edit);
+
+                       warn "# edit $path $i $old -> $new\n";
                        $loaded->{$path}->{data}->{items}->[$i]->{$name} = $v;
 
                        if ( defined $loaded->{$path}->{sorted}->{$name} ) {
@@ -747,13 +848,25 @@ sub edit {
 
 sub save {
        my $self = shift;
-       my $path = $self->param('path');
-       $path  ||= $self->session('path');
-
+       my $path = $self->_param_or_session('path');
        my $dump_path = $self->_save( $path );
        $self->session('save_path' => 0);
 
        $self->redirect_to( '/data/items' );
 }
 
+sub export {
+       my $self = shift;
+       $self->render( export => [
+               map { s{^.+/public/export/}{}; $_ }
+               glob( $self->_export_path . '*' )
+       ] );
+}
+
+sub __loaded_paths {
+       return
+               grep { defined $loaded->{$_}->{data} }
+               keys %$loaded;
+}
+
 1;
index 7d07948..25b0747 100644 (file)
@@ -174,3 +174,26 @@ a.facet {
        text-decoration: line-through;
 }
 
+/* /changes/edits */
+
+tr.edit pre {
+       color: #000;
+       font-size: 70%;
+}
+
+tr.unknown {
+       background: #eee;
+}
+
+tr.found {
+       background: #cfc;
+}
+
+tr.missing {
+       background: #fcc;
+}
+
+tr.hidden {
+       display: none;
+}
+
diff --git a/script/changes b/script/changes
new file mode 100755 (executable)
index 0000000..ca31147
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Storable;
+use Mojo::Client;
+use Data::Dump qw(dump);
+
+my $url = 'http://localhost:3000/data/edit';
+my $max = 1;
+
+my @changes = @ARGV;
+
+my $t = Mojo::Client->new;
+$t->max_redirects( 1 );
+
+foreach my $c ( @changes ) {
+
+       print "# $c\n";
+
+       my $params = retrieve $c;
+       my $hash = $params->to_hash;
+       $hash->{time} = $1 if $c =~ m{/(\d+\.\d+)\.data\.edit};
+
+       warn "# hash ",dump($hash);
+
+       my $tx = $t->post_form( $url => $hash );
+       if ( my $res = $tx->success) { print $res->body }
+       else {
+               my ($code, $message) = $tx->error;
+               die "Error: $message";
+       }
+
+#      last if $max-- == 0;
+}
index 9dc92f0..4e1f431 100644 (file)
@@ -9,10 +9,17 @@ items:
 <a href="<%= url_for( controller => 'data', action => 'items' )->query( show => $show ) %>" <%= $class %>><%= $show %></a>
 % }
 
+<span class=changes>
+
 % if ( my $path = session('save_path') ) {
 <a class=save_changes title="<%= $path %>" href="<%= url_for( controller => 'data', action => 'save', path => $path ) %>">save</a>
 % }
-<a class=changes href="<%= url_for( controller => 'changes', action => 'index' ) %>">changes</a>
+% if ( $self->can('_export_path') && glob $self->_export_path('*') ) {
+<a href="<%= url_for( controller => 'data', action => 'export' ) %>">export</a>
+% }
+<a href="<%= url_for( controller => 'changes', action => 'edits' ) %>">edits</a>
+<a href="<%= url_for( controller => 'changes', action => 'index' ) %>">changes</a>
+</span>
 
 </div>
 
diff --git a/templates/changes/edits.html.ep b/templates/changes/edits.html.ep
new file mode 100644 (file)
index 0000000..953b989
--- /dev/null
@@ -0,0 +1,75 @@
+% layout 'ui';
+
+
+% my $dump = param('dump');
+% my $apply_on_path = param('apply_on_path');
+
+<form method=post>
+<input type=submit value="Apply"> on
+<select name=apply_on_path>
+% foreach my $p ( @$loaded ) {
+<option<%= $p eq $apply_on_path ? ' selected' : '' %>><%= $p %></option>
+% }
+</select>
+<label><input type=checkbox name=dump <%= $dump ? 'checked' : '' %>>dump</label>
+
+% if ( $apply_on_path ) {
+<ul id=status>
+%  foreach my $status ( keys %$stats ) {
+<li><label>
+<input name=show type=checkbox value="<%= $status %>" checked>
+<%= $status %>
+<span class=count><%= $stats->{$status} %></span>
+</label>
+%  }
+</ul>
+
+<input type=submit name=commit value="Commit changes">
+
+% }
+
+</form>
+
+<table>
+<tr><th></th><th>old</th><th>new</th></tr>
+
+% foreach my $e ( @$edits ) {
+<tr class="edit <%= $e->{_status} || 'unknown' %>">
+<td>
+<%= $e->{time} %>
+<tt><%= $e->{column} %></tt>
+%  if ( my $status = $e->{_status} ) {
+%    my ( $pk, $id ) = %{ $e->{unique} };
+<a href="<%= url_for( controller => 'data', action => 'filter' )->query( filter_name => $pk, filter_vals => $id ) %>"><%= $id %></a>
+<%= $status %>
+%  } else {
+<a href="<%= url_for( action => 'edit' )->query( remove => $e->{time} ) %>">remove</a>
+%  }
+
+</td><td><%== defined $e->{old} && join('<span class=d>&para;</span>', @{$e->{old}}) %>
+</td><td><%== defined $e->{new} && join('<span class=d>&para;</span>', @{$e->{new}}) %>
+
+%  if ( $dump ) {
+</td><td><pre class=debug><%= dumper $e %></pre>
+%  }
+</tr>
+% }
+
+</table>
+
+<pre class=debug>
+<%= dumper( $stats ) %>
+</pre>
+
+<script type="text/javascript">
+
+$(document).ready( function(){
+       console.debug('ready');
+       $('ul#status > li input[type=checkbox]').click( function(){
+               var toggle = this.value;
+               console.debug('click',this,toggle);
+               $('tr.'+toggle).toggleClass('hidden');
+       });
+});
+
+</script>
index 8dd4e5c..eaf50ab 100644 (file)
@@ -5,6 +5,9 @@
 % $action = url_for( controller => 'data', action => $action );
 <form method=post action=<%= $action %>>
 <input type=submit value="<%= $action %>">
+<tt><%= $uid %></tt>
+% my $t = $1 if $uid =~ m/^(\d+\.\d+)/;
+<input type=hidden name="time" value="<%= $t %>">
 % if ( my $master = $ENV{'MASTER'} ) {
 <input class=replication type=checkbox name="_master" value="<%= $master %>" title="replicate to <%= $master %>">
 % }
index 50f7f6b..5ea9dff 100644 (file)
@@ -34,6 +34,9 @@ $(document).ready(function() {
 <input type=checkbox name=columns value="<%= $n %>" <%= $checked->{$n} ? 'checked' : '' %>>
 <%= $n %>
 <span class="count"><%= $stats->{$n}->{count} %></span>
+% if ( defined $stats->{$n}->{unique} ) {
+<span title="unique">&#9997;</a>
+% }
 </label>
 % }
 </ul>
@@ -42,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>
diff --git a/templates/data/export.html.ep b/templates/data/export.html.ep
new file mode 100644 (file)
index 0000000..2333993
--- /dev/null
@@ -0,0 +1,9 @@
+% layout 'default';
+
+<ul>
+% foreach my $e ( @$export ) {
+<li><a target="<%= $e %>" href="/export/<%= $e %>"><%= $e %></a>
+% }
+</ul>
+
+<pre class=debug><%= dumper $export %></pre>
index ffa7dd5..b14bea3 100644 (file)
@@ -36,6 +36,7 @@
 </ul>
 
 <input type=submit value="Filter <%= $name %>">
+<input type=text name=_permanent>
 
 </form>
 
index 83c03f7..3406459 100644 (file)
@@ -8,7 +8,7 @@
 <input type=submit value="Load">
 
 <table>
-<tr><th rowspan=2>name</th><th colspan=2>size</th><th rowspan=2>items</th><th rowspan=2 title="loaded in memory">m</th><th>columns</th></tr>
+<tr><th rowspan=2>name</th><th colspan=2>size</th><th rowspan=2>items</th><th rowspan=2>edits</th><th rowspan=2 title="loaded in memory">m</th><th colspan=2>columns</th></tr>
 <tr><th>disk</th><th>storable</th></tr>
 % foreach my $n ( @$files ) {
 <tr><td>
@@ -19,6 +19,7 @@
 </td><td class=bytes><%= $size->{$n} %>
 </td><td class=bytes><%= -s $dump_path->{$n} %>
 </td><td align=right><%= defined $loaded->{$n}->{data} ? $#{ $loaded->{$n}->{data}->{items} } + 1 : '' %>
+</td><td align=right><%= defined $edits->{$n} ? $#{ $edits->{$n} } + 1 : '' %>
 </td><td><input name=paths type=checkbox value="<%= $n %>" <%= defined $loaded->{$n}->{stats} ? 'checked' : '' %>>
 </td><td>
 %  if ( defined $loaded->{$n}->{columns} ) {
@@ -35,7 +36,7 @@
 
 </form>
 
-<pre class=debug><%= dumper $changes %></pre>
+<pre class=debug><%= dumper $edits %></pre>
 <pre class=debug><%= dumper $loaded %></pre>
 <pre class=debug><%= dumper $filters %></pre>
 <pre class=debug><%= dumper $dump_path %></pre>