~percona-toolkit-dev/percona-toolkit/fix-dl-ts-bug-1195034

« back to all changes in this revision

Viewing changes to lib/QueryReportFormatter.pm

  • Committer: Brian Fraser
  • Date: 2013-04-16 20:48:05 UTC
  • mfrom: (571.5.1 percona-toolkit)
  • Revision ID: brian.fraser@percona.com-20130416204805-ercplkuen4d6emcv
Merged fix-1160918-restore-show-all

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
   default => sub { [qw(pct total min max avg 95% stddev median)] },
85
85
);
86
86
 
 
87
has show_all => (
 
88
   is      => 'ro',
 
89
   isa     => 'HashRef',
 
90
   default => sub { {} },
 
91
);
 
92
 
87
93
has ReportFormatter => (
88
94
   is      => 'ro',
89
95
   isa     => 'ReportFormatter',
1114
1120
# Does pretty-printing for lists of strings like users, hosts, db.
1115
1121
sub format_string_list {
1116
1122
   my ( $self, $attrib, $vals, $class_cnt ) = @_;
1117
 
 
 
1123
   
1118
1124
   # Only class result values have unq.  So if unq doesn't exist,
1119
1125
   # then we've been given global values.
1120
1126
   if ( !exists $vals->{unq} ) {
1121
1127
      return ($vals->{cnt});
1122
1128
   }
1123
1129
 
 
1130
   my $show_all = $self->show_all();
 
1131
 
1124
1132
   my $cnt_for = $vals->{unq};
1125
1133
   if ( 1 == keys %$cnt_for ) {
1126
1134
      my ($str) = keys %$cnt_for;
1146
1154
      }
1147
1155
      my $p = percentage_of($cnt_for->{$str}, $class_cnt);
1148
1156
      $print_str .= " ($cnt_for->{$str}/$p%)";
 
1157
      if ( !$show_all->{$attrib} ) {
 
1158
         last if (length $line) + (length $print_str)  > LINE_LENGTH - 27;
 
1159
      }
1149
1160
      $line .= "$print_str, ";
1150
1161
      $i++;
1151
1162
   }