+ } elsif ( $format eq 'key_distinct' ) {
+
+ my $found;
+ my @rows = grep {
+ push @{ $found->{ $_->{key} } }, $_->{id};
+ $#{ $found->{ $_->{key} } } == 0; # take just first registration
+ } @{ $json->{rows} };
+
+ $json->{rows} = [ map {
+ $_->{distinct_ids} = $found->{ $_->{key} };
+ $_;
+ } @rows ];
+
+ $json->{distinct_rows} = scalar @{ $json->{rows} };
+ warn "## distinct stats ", dump( $found );
+
+ } elsif ( $format ) {
+
+ die "unknown format: $format";
+