Bladeren bron

abstracted point values to cache file

Bryan Allred 10 jaren geleden
bovenliggende
commit
9f979e178b
3 gewijzigde bestanden met toevoegingen van 129 en 73 verwijderingen
  1. 109 53
      Dashboard.cs
  2. 2 2
      Penalties.cs
  3. 18 18
      Rewards.cs

+ 109 - 53
Dashboard.cs

13
	/// </summary>
13
	/// </summary>
14
	public class Dashboard
14
	public class Dashboard
15
	{
15
	{
16
		/// <summary>
17
		/// Gets or sets the server.
18
		/// </summary>
19
		/// <value>
20
		/// The server.
21
		/// </value>
22
		public Uri Server { get; set; }
23
24
		/// <summary>
25
		/// Gets or sets the selected item.
26
		/// </summary>
27
		/// <value>
28
		/// The selected item.
29
		/// </value>
30
		public int SelectedItem { get; set; }
31
32
		/// <summary>
16
		/// <summary>
33
		/// Gets or sets the date refresh.
17
		/// Gets or sets the date refresh.
34
		/// </summary>
18
		/// </summary>
38
		public DateTime? DateRefresh { get; set; }
22
		public DateTime? DateRefresh { get; set; }
39
23
40
		/// <summary>
24
		/// <summary>
41
		/// Gets or sets the scores.
25
		/// Gets or sets the selected item.
42
		/// </summary>
26
		/// </summary>
43
		/// <value>
27
		/// <value>
44
		/// The scores.
28
		/// The selected item.
45
		/// </value>
29
		/// </value>
46
		private IDictionary<string, double> Scores { get; set; }
30
		public int SelectedItem { get; set; }
47
31
48
		/// <summary>
32
		/// <summary>
49
		/// Gets or sets the highlighted scores.
33
		/// Gets or sets the server.
50
		/// </summary>
34
		/// </summary>
51
		/// <value>
35
		/// <value>
52
		/// The highlighted scores.
36
		/// The server.
53
		/// </value>
37
		/// </value>
54
		private IList<string> HighlightedScores { get; set; }
38
		public Uri Server { get; set; }
55
39
56
		/// <summary>
40
		/// <summary>
57
		/// Gets the cache file.
41
		/// Gets the cache file.
85
		private int Commits { get; set; }
69
		private int Commits { get; set; }
86
70
87
		/// <summary>
71
		/// <summary>
88
		/// Gets or sets the projects.
72
		/// Gets the height.
89
		/// </summary>
73
		/// </summary>
90
		/// <value>
74
		/// <value>
91
		/// The projects.
75
		/// The height.
92
		/// </value>
76
		/// </value>
93
		private int Projects { get; set; }
77
		private int Height
78
		{
79
			get
80
			{
81
				return Console.WindowHeight - 2;
82
			}
83
		}
94
84
95
		/// <summary>
85
		/// <summary>
96
		/// Gets or sets the work items.
86
		/// Gets or sets the highlighted scores.
97
		/// </summary>
87
		/// </summary>
98
		/// <value>
88
		/// <value>
99
		/// The work items.
89
		/// The highlighted scores.
100
		/// </value>
90
		/// </value>
101
		private int WorkItems { get; set; }
91
		private IList<string> HighlightedScores { get; set; }
102
92
103
		/// <summary>
93
		/// <summary>
104
		/// Gets the height.
94
		/// Gets or sets the points.
105
		/// </summary>
95
		/// </summary>
106
		/// <value>
96
		/// <value>
107
		/// The height.
97
		/// The points.
108
		/// </value>
98
		/// </value>
109
		private int Height
110
		{
111
			get
112
			{
113
				return Console.WindowHeight - 2;
114
			}
115
		}
99
		private IDictionary<string, double> Points { get; set; }
100
101
		/// <summary>
102
		/// Gets or sets the projects.
103
		/// </summary>
104
		/// <value>
105
		/// The projects.
106
		/// </value>
107
		private int Projects { get; set; }
108
109
		/// <summary>
110
		/// Gets or sets the scores.
111
		/// </summary>
112
		/// <value>
113
		/// The scores.
114
		/// </value>
115
		private IDictionary<string, double> Scores { get; set; }
116
116
117
		/// <summary>
117
		/// <summary>
118
		/// Gets the width.
118
		/// Gets the width.
128
			}
128
			}
129
		}
129
		}
130
130
131
		/// <summary>
132
		/// Gets or sets the work items.
133
		/// </summary>
134
		/// <value>
135
		/// The work items.
136
		/// </value>
137
		private int WorkItems { get; set; }
138
131
		/// <summary>
139
		/// <summary>
132
		/// Initializes a new instance of the <see cref="Dashboard" /> class.
140
		/// Initializes a new instance of the <see cref="Dashboard" /> class.
133
		/// </summary>
141
		/// </summary>
142
			this.SelectedItem = 1;
150
			this.SelectedItem = 1;
143
			this.Scores = new Dictionary<string, double>();
151
			this.Scores = new Dictionary<string, double>();
144
			this.HighlightedScores = new List<string>();
152
			this.HighlightedScores = new List<string>();
153
			this.Points = new Dictionary<string, double>()
154
			{
155
				{ Penalties.LackingVerbosity, -0.2 },
156
				{ Penalties.LackOfPurpose, -0.2 },
157
				{ Rewards.BugReport, 0.7 },
158
				{ Rewards.Collaboration, 0.7 },
159
				{ Rewards.CreatedWork, 0.02 },
160
				{ Rewards.DueDiligence, 0.4 },
161
				{ Rewards.FinishWork, 0.5 },
162
				{ Rewards.HouseCleaning, 0.1 },
163
				{ Rewards.Participation, 0.3 },
164
				{ Rewards.TakingOwnership, 0.1 },
165
				{ Rewards.Verbosity, 0.8 }
166
			};
145
167
146
			var cacheFile = new FileInfo(this.CacheFile);
168
			var cacheFile = new FileInfo(this.CacheFile);
147
169
187
									this.Scores[fields[1]] = points;
209
									this.Scores[fields[1]] = points;
188
								}
210
								}
189
211
212
								break;
213
214
							case "point":
215
								var pointValue = Convert.ToDouble(fields[2]);
216
217
								if (!this.Points.ContainsKey(fields[1]))
218
								{
219
									this.Points.Add(fields[1], pointValue);
220
								}
221
								else
222
								{
223
									this.Points[fields[1]] = pointValue;
224
								}
225
190
								break;
226
								break;
191
						}
227
						}
192
					}
228
					}
214
				}
250
				}
215
251
216
				// Get a point for participation.
252
				// Get a point for participation.
217
				this.Scores[personOfInterest] += Rewards.Participation;
253
				this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
218
254
219
				// Handle points for commits with comments.
255
				// Handle points for commits with comments.
220
				if (string.IsNullOrWhiteSpace(commit.Comment))
256
				if (string.IsNullOrWhiteSpace(commit.Comment))
221
				{
257
				{
222
					this.Scores[personOfInterest] += Penalties.LackingVerbosity;
258
					this.Scores[personOfInterest] += this.GetPoints(Penalties.LackingVerbosity);
223
				}
259
				}
224
				else
260
				else
225
				{
261
				{
226
					this.Scores[personOfInterest] += Rewards.Verbosity;
262
					this.Scores[personOfInterest] += this.GetPoints(Rewards.Verbosity);
227
				}
263
				}
228
264
229
				// Handle points with associating commits with actual work.
265
				// Handle points with associating commits with actual work.
230
				if (commit.AssociatedWorkItems.Count() == 0)
266
				if (commit.AssociatedWorkItems.Count() == 0)
231
				{
267
				{
232
					this.Scores[personOfInterest] += Penalties.LackOfPurpose;
268
					this.Scores[personOfInterest] += this.GetPoints(Penalties.LackOfPurpose);
233
				}
269
				}
234
				else
270
				else
235
				{
271
				{
236
					this.Scores[personOfInterest] += Rewards.Collaboration;
272
					this.Scores[personOfInterest] += this.GetPoints(Rewards.Collaboration);
237
				}
273
				}
238
			}
274
			}
239
		}
275
		}
276
						}
312
						}
277
313
278
						// Add points for collaboration.
314
						// Add points for collaboration.
279
						this.Scores[item.ChangedBy] += Rewards.Collaboration;
315
						this.Scores[item.ChangedBy] += this.GetPoints(Rewards.Collaboration);
280
					}
316
					}
281
				}
317
				}
282
				else
318
				else
284
					if (!string.IsNullOrWhiteSpace(item.CreatedBy))
320
					if (!string.IsNullOrWhiteSpace(item.CreatedBy))
285
					{
321
					{
286
						// They must have updated something right?
322
						// They must have updated something right?
287
						this.Scores[item.CreatedBy] += Rewards.Participation;
323
						this.Scores[item.CreatedBy] += this.GetPoints(Rewards.Participation);
288
					}
324
					}
289
				}
325
				}
290
326
298
					switch (item.Type.Name.ToLower())
334
					switch (item.Type.Name.ToLower())
299
					{
335
					{
300
						case "product backlog item":
336
						case "product backlog item":
301
							this.Scores[personOfInterest] += Rewards.Participation;
337
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
302
							break;
338
							break;
303
339
304
						case "user story":
340
						case "user story":
305
							this.Scores[personOfInterest] += Rewards.Participation;
341
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
306
							break;
342
							break;
307
343
308
						case "feature":
344
						case "feature":
309
							this.Scores[personOfInterest] += Rewards.Participation;
345
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
310
							break;
346
							break;
311
347
312
						case "task":
348
						case "task":
313
							this.Scores[personOfInterest] += Rewards.CreatedWork;
349
							this.Scores[personOfInterest] += this.GetPoints(Rewards.CreatedWork);
314
							break;
350
							break;
315
351
316
						case "impediment":
352
						case "impediment":
317
						case "issue":
353
						case "issue":
318
						case "bug":
354
						case "bug":
319
							this.Scores[personOfInterest] += Rewards.BugReport;
355
							this.Scores[personOfInterest] += this.GetPoints(Rewards.BugReport);
320
							break;
356
							break;
321
357
322
						case "test case":
358
						case "test case":
323
						case "shared steps":
359
						case "shared steps":
324
							this.Scores[personOfInterest] += Rewards.CreatedWork;
360
							this.Scores[personOfInterest] += this.GetPoints(Rewards.CreatedWork);
325
							break;
361
							break;
326
362
327
						default:
363
						default:
338
						case "approved":
374
						case "approved":
339
						case "active":
375
						case "active":
340
						case "in progress":
376
						case "in progress":
341
							this.Scores[personOfInterest] += Rewards.TakingOwnership;
377
							this.Scores[personOfInterest] += this.GetPoints(Rewards.TakingOwnership);
342
							break;
378
							break;
343
379
344
						case "done":
380
						case "done":
345
						case "committed":
381
						case "committed":
346
						case "resolved":
382
						case "resolved":
347
						case "closed":
383
						case "closed":
348
							this.Scores[personOfInterest] += Rewards.FinishWork;
384
							this.Scores[personOfInterest] += this.GetPoints(Rewards.FinishWork);
349
							break;
385
							break;
350
386
351
						case "removed":
387
						case "removed":
352
							this.Scores[personOfInterest] += Rewards.HouseCleaning;
388
							this.Scores[personOfInterest] += this.GetPoints(Rewards.HouseCleaning);
353
							break;
389
							break;
354
390
355
						default:
391
						default:
378
				{
414
				{
379
					writer.WriteLine(string.Format("{0};{1};{2}", "score", score.Key, score.Value));
415
					writer.WriteLine(string.Format("{0};{1};{2}", "score", score.Key, score.Value));
380
				}
416
				}
417
418
				foreach (var point in this.Points)
419
				{
420
					writer.WriteLine(string.Format("{0};{1};{2}", "point", point.Key, point.Value));
421
				}
381
			}
422
			}
382
		}
423
		}
383
424
481
			}
522
			}
482
		}
523
		}
483
524
525
		/// <summary>
526
		/// Gets the points.
527
		/// </summary>
528
		/// <param name="action">The action.</param>
529
		/// <returns>Returns the point value for a specific action.</returns>
530
		private double GetPoints(string action)
531
		{
532
			if (this.Points.ContainsKey(action))
533
			{
534
				return this.Points[action];
535
			}
536
537
			return 0.0;
538
		}
539
484
		/// <summary>
540
		/// <summary>
485
		/// Statisticses this instance.
541
		/// Statisticses this instance.
486
		/// </summary>
542
		/// </summary>

+ 2 - 2
Penalties.cs

8
		/// <summary>
8
		/// <summary>
9
		/// The lacking verbosity.
9
		/// The lacking verbosity.
10
		/// </summary>
10
		/// </summary>
11
		public const double LackingVerbosity = -0.2;
11
		public const string LackingVerbosity = "LackingVerbosity";
12
12
13
		/// <summary>
13
		/// <summary>
14
		/// The lack of purpose.
14
		/// The lack of purpose.
15
		/// </summary>
15
		/// </summary>
16
		public const double LackOfPurpose = -0.2;
16
		public const string LackOfPurpose = "LackOfPurpose";
17
	}
17
	}
18
}
18
}

+ 18 - 18
Rewards.cs

6
	public static class Rewards
6
	public static class Rewards
7
	{
7
	{
8
		/// <summary>
8
		/// <summary>
9
		/// The participation.
10
		/// </summary>
11
		public const double Participation = 0.3;
12
13
		/// <summary>
14
		/// The verbosity.
9
		/// The bug report.
15
		/// </summary>
10
		/// </summary>
16
		public const double Verbosity = 0.8;
11
		public const string BugReport = "BugReport";
17
12
18
		/// <summary>
13
		/// <summary>
19
		/// The collaboration.
14
		/// The collaboration.
20
		/// </summary>
15
		/// </summary>
21
		public const double Collaboration = 0.7;
16
		public const string Collaboration = "Collaboration";
22
17
23
		/// <summary>
18
		/// <summary>
24
		/// The house cleaning.
19
		/// The created work.
25
		/// </summary>
20
		/// </summary>
26
		public const double HouseCleaning = 0.1;
21
		public const string CreatedWork = "CreatedWork";
27
22
28
		/// <summary>
23
		/// <summary>
29
		/// The due diligence.
24
		/// The due diligence.
30
		/// </summary>
25
		/// </summary>
31
		public const double DueDiligence = 0.4;
26
		public const string DueDiligence = "DueDiligence";
32
27
33
		/// <summary>
28
		/// <summary>
34
		/// The bug report.
29
		/// The finish work.
35
		/// </summary>
30
		/// </summary>
36
		public const double BugReport = 0.7;
31
		public const string FinishWork = "FinishWork";
37
32
38
		/// <summary>
33
		/// <summary>
39
		/// The created work.
34
		/// The house cleaning.
40
		/// </summary>
35
		/// </summary>
41
		public const double CreatedWork = 0.02;
36
		public const string HouseCleaning = "HouseCleaning";
42
37
43
		/// <summary>
38
		/// <summary>
44
		/// The finish work.
39
		/// The participation.
45
		/// </summary>
40
		/// </summary>
46
		public const double FinishWork = 0.5;
41
		public const string Participation = "Participation";
47
42
48
		/// <summary>
43
		/// <summary>
49
		/// The taking ownership.
44
		/// The taking ownership.
50
		/// </summary>
45
		/// </summary>
51
		public const double TakingOwnership = 0.1;
46
		public const string TakingOwnership = "TakingOwnership";
47
48
		/// <summary>
49
		/// The verbosity.
50
		/// </summary>
51
		public const string Verbosity = "Verbosity";
52
	}
52
	}
53
}
53
}