Browse Source

misc work and add screenshot

tags/0.1.0
Zane C. B-H 1 month ago
parent
commit
ac929cff82
4 changed files with 51 additions and 2 deletions
  1. 4
    0
      Git-PunchCard/Changes
  2. 19
    2
      Git-PunchCard/bin/punchcard-git
  3. 28
    0
      Git-PunchCard/lib/Git/PunchCard.pm
  4. BIN
      screenshot.png

+ 4
- 0
Git-PunchCard/Changes View File

@@ -1,5 +1,9 @@
1 1
 Revision history for Git-PunchCard
2 2
 
3
+0.1.0	 2019-07-15/22:15
4
+		 - Display max.
5
+		 - Add avagerage/min.
6
+
3 7
 0.0.1	 2019-07-15/06:20
4 8
 		 - Set LC_ALL=C when calling git.
5 9
 		 - Properly set hourly max for the day.

+ 19
- 2
Git-PunchCard/bin/punchcard-git View File

@@ -129,7 +129,10 @@ my $table=Text::Table->new(
129 129
 						   '21',
130 130
 						   '22',
131 131
 						   '23',
132
-						   'Total'
132
+						   'Total',
133
+						   'Max',
134
+						   'Avg',
135
+						   'Min'
133 136
 );
134 137
 
135 138
 my $card=$gpc->get_card;
@@ -145,14 +148,28 @@ foreach my $day ( @days ){
145 148
 		push( @line, color($colors[$color_to_use]).$card->{$day}{$hour}.color('WHITE') );
146 149
 	}
147 150
 
151
+	my $min_color=13*($card->{$day}{min}/$card->{max});
152
+	my $average_color=13*($card->{$day}{average}/$card->{max});
153
+	my $max_color=13*($card->{$day}{max}/$card->{max});
154
+	
148 155
 	push( @line, $card->{$day}{total}.color('WHITE') );
156
+	push( @line, color($colors[$max_color]).$card->{$day}{max}.color('WHITE') );
157
+	push( @line, color($colors[$average_color]).sprintf('%.1f',$card->{$day}{average}).color('WHITE') );
158
+	push( @line, color($colors[$min_color]).$card->{$day}{min}.color('WHITE') );
149 159
 
150 160
 	push( @data, \@line );
151 161
 }
152 162
 
153 163
 $table->load( @data );
154 164
 
155
-print $table."\nTotal: ".$card->{total}."\nHourly Max=".$card->{max}."\nAverage=".$card->{average}."\n";
165
+my $min_color=13*($card->{min}/$card->{max});
166
+my $average_color=13*($card->{average}/$card->{max});
167
+
168
+print $table.
169
+"\nTotal: ".$card->{total}.
170
+"\nMax=".color($colors[13]).$card->{max}.color('WHITE').
171
+"\nAverage=".color($colors[$average_color]).sprintf("%.1f",$card->{average}).color('WHITE').
172
+"\nMin=".color($colors[$min_color]).$card->{min}.color('WHITE')."\n";
156 173
 
157 174
 =head1 NAME
158 175
 

+ 28
- 0
Git-PunchCard/lib/Git/PunchCard.pm View File

@@ -98,9 +98,13 @@ sub new {
98 98
 			  card=>{
99 99
 					 total=>0,
100 100
 					 max=>0,
101
+					 average=>0,
102
+					 min=>9999999999999999999999999999999999,
101 103
 					 Sun=>{
102 104
 						   total=>0,
103 105
 						   max=>0,
106
+						   average=>0,
107
+						   min=>9999999999999999999999999999999999,
104 108
 						   '00'=>0,
105 109
 						   '01'=>0,
106 110
 						   '02'=>0,
@@ -129,6 +133,8 @@ sub new {
129 133
 					 Mon=>{
130 134
 						   total=>0,
131 135
 						   max=>0,
136
+						   average=>0,
137
+						   min=>9999999999999999999999999999999999,
132 138
 						   '00'=>0,
133 139
 						   '01'=>0,
134 140
 						   '02'=>0,
@@ -157,6 +163,8 @@ sub new {
157 163
 					 Tue=>{
158 164
 						   total=>0,
159 165
 						   max=>0,
166
+						   average=>0,
167
+						   min=>9999999999999999999999999999999999,
160 168
 						   '00'=>0,
161 169
 						   '01'=>0,
162 170
 						   '02'=>0,
@@ -185,6 +193,8 @@ sub new {
185 193
 					 Wed=>{
186 194
 						   total=>0,
187 195
 						   max=>0,
196
+						   average=>0,
197
+						   min=>9999999999999999999999999999999999,
188 198
 						   '00'=>0,
189 199
 						   '01'=>0,
190 200
 						   '02'=>0,
@@ -213,6 +223,8 @@ sub new {
213 223
 					 Thu=>{
214 224
 						   total=>0,
215 225
 						   max=>0,
226
+						   average=>0,
227
+						   min=>9999999999999999999999999999999999,
216 228
 						   '00'=>0,
217 229
 						   '01'=>0,
218 230
 						   '02'=>0,
@@ -241,6 +253,8 @@ sub new {
241 253
 					 Fri=>{
242 254
 						   total=>0,
243 255
 						   max=>0,
256
+						   average=>0,
257
+						   min=>9999999999999999999999999999999999,
244 258
 						   '00'=>0,
245 259
 						   '01'=>0,
246 260
 						   '02'=>0,
@@ -269,6 +283,8 @@ sub new {
269 283
 					 Sat=>{
270 284
 						   total=>0,
271 285
 						   max=>0,
286
+						   average=>0,
287
+						   min=>9999999999999999999999999999999999,
272 288
 						   '00'=>0,
273 289
 						   '01'=>0,
274 290
 						   '02'=>0,
@@ -367,6 +383,18 @@ sub dir {
367 383
 
368 384
 	$self->{card}{average}= $self->{card}{total} / 168 ;
369 385
 
386
+	foreach my $day ( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ){
387
+		for my $hour ( '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23' ){
388
+			if ( $self->{card}{$day}{$hour} < $self->{card}{$day}{min} ){
389
+				$self->{card}{$day}{min}=$self->{card}{$day}{$hour};
390
+			}
391
+			if ( $self->{card}{$day}{$hour} < $self->{card}{min} ){
392
+				$self->{card}{min}=$self->{card}{$day}{$hour};
393
+			}
394
+		}
395
+	}
396
+
397
+	
370 398
 	return 1;
371 399
 }
372 400
 

BIN
screenshot.png View File


Loading…
Cancel
Save