small circular points
[MojoFacets.git] / script / actions-to-changes
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use Storable;
7 use Mojo::Client;
8 use Data::Dump qw(dump);
9
10 my $url = 'http://localhost:3000/data/edit';
11 my $max = 1;
12
13 my @actions = @ARGV;
14
15 my $t = Mojo::Client->new;
16 $t->max_redirects( 1 );
17
18 my $stats;
19
20 foreach my $c ( sort {
21         my $at = $1 if $a =~ m/(\d+\.\d+)/;
22         my $bt = $1 if $b =~ m/(\d+\.\d+)/;
23         $at <=> $bt
24 } @actions ) {
25
26         print "# $c\n";
27
28         my $params = retrieve $c;
29         my $hash = $params->to_hash;
30         $hash->{time} = $1 if $c =~ m{/(\d+\.\d+)\.data\.edit};
31
32         warn "# hash ",dump($hash);
33
34         my $tx = $t->post_form( $url => $hash );
35         if ( my $res = $tx->success) {
36                 my $code = $res->code;
37                 $stats->{$code}++;
38                 print $code, ' ', $res->body
39         } else {
40                 my ($code, $message) = $tx->error;
41                 die "Error: $message";
42         }
43
44 #       last if $max-- == 0;
45 }
46
47 warn "# stats ",dump($stats);