use File::Path qw(make_path remove_tree);
use MongoDB;
-my $name = 'pxelator';
+my $name = shift @ARGV || 'pxelator';
my $conn = MongoDB::Connection->new;
my $db = $conn->get_database( $name );
my $total = <$sock>;
$total =~ s{^.*total_rows\D+(\d+).+$}{$1};
-warn "# total: $total\n";
+
+$|=1;
+print "# $name total: $total\n";
+
+my $start_t = time();
+my $count = 0;
+
while(<$sock>) {
if ( /"id":"([^"]+)"/ ) {
s/,[\r\n]+$//; # cleanup JSON
my $json = from_json( $_ );
$audit->insert( $json->{doc} );
- print STDERR ".";
+ printf " %d/%d %.2f%% %.2f/s\r", $count, $total
+ , ( $count / $total ) * 100
+ , ( $count / ( time() - $start_t ) )
+ if ++$count % 1000 == 0;
} else {
warn "UNKNOWN: $_";
}