correctly load multiple params for paths
[MojoFacets.git] / script / actions-to-changes
index ca31147..f2a083b 100755 (executable)
@@ -10,12 +10,18 @@ use Data::Dump qw(dump);
 my $url = 'http://localhost:3000/data/edit';
 my $max = 1;
 
-my @changes = @ARGV;
+my @actions = @ARGV;
 
 my $t = Mojo::Client->new;
 $t->max_redirects( 1 );
 
-foreach my $c ( @changes ) {
+my $stats;
+
+foreach my $c ( sort {
+       my $at = $1 if $a =~ m/(\d+\.\d+)/;
+       my $bt = $1 if $b =~ m/(\d+\.\d+)/;
+       $at <=> $bt
+} @actions ) {
 
        print "# $c\n";
 
@@ -26,11 +32,16 @@ foreach my $c ( @changes ) {
        warn "# hash ",dump($hash);
 
        my $tx = $t->post_form( $url => $hash );
-       if ( my $res = $tx->success) { print $res->body }
-       else {
+       if ( my $res = $tx->success) {
+               my $code = $res->code;
+               $stats->{$code}++;
+               print $code, ' ', $res->body
+       } else {
                my ($code, $message) = $tx->error;
                die "Error: $message";
        }
 
 #      last if $max-- == 0;
 }
+
+warn "# stats ",dump($stats);