extract path from full_path if missing
[MojoFacets.git] / lib / MojoFacets / Actions.pm
index 969f967..7d06c71 100644 (file)
@@ -7,7 +7,6 @@ use base 'Mojolicious::Controller';
 
 use Storable;
 use Data::Dump qw(dump);
-use MojoFacets::Data;
 
 sub index {
        my $self = shift;
@@ -42,67 +41,4 @@ sub view {
        $self->render( change => retrieve( "/tmp/actions/$uid" ), uid => $uid );
 }
 
-sub _changes_path {
-       my $self = shift;
-       my $path = $self->param('path') || $self->session('path');
-       $self->app->home->rel_dir('data') . '/' . $path . '.changes';
-}
-
-sub changes {
-       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 $changes;
-       my $stats;
-       my $glob = $self->_changes_path . '/*';
-       foreach my $t ( sort { $a cmp $b } glob $glob ) {
-               my $e = retrieve($t);
-               if ( $items ) {
-                       die "no unique in ", dump($e) unless exists $e->{unique};
-                       my ($pk,$id) = %{ $e->{unique} };
-                       if ( ! $pk ) {
-                               $e->{_status} = 'skip';
-                               $stats->{skip}++;
-                               push @$changes, $e;
-                               next;
-                       }
-                       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 @$changes, $e;
-       }
-
-       my @loaded = MojoFacets::Data::__loaded_paths();
-       warn "# loaded paths ",dump @loaded;
-
-       $self->render( changes => $changes, loaded => \@loaded, stats => $stats );
-}
-
-sub remove {
-       my $self = shift;
-
-       if ( my $t = $self->param('time') ) {
-               unlink $self->_changes_path . '/' . $t;
-       }
-
-       $self->redirect_to('/actions/changes');
-}
-
 1;