瀏覽代碼

abstracted point values to cache file

Bryan Allred 10 年之前
父節點
當前提交
9f979e178b
共有 3 個文件被更改,包括 129 次插入73 次删除
  1. 109 53
      Dashboard.cs
  2. 2 2
      Penalties.cs
  3. 18 18
      Rewards.cs

+ 109 - 53
Dashboard.cs

@ -13,22 +13,6 @@ namespace pulse
13 13
	/// </summary>
14 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 16
		/// <summary>
33 17
		/// Gets or sets the date refresh.
34 18
		/// </summary>
@ -38,20 +22,20 @@ namespace pulse
38 22
		public DateTime? DateRefresh { get; set; }
39 23
40 24
		/// <summary>
41
		/// Gets or sets the scores.
25
		/// Gets or sets the selected item.
42 26
		/// </summary>
43 27
		/// <value>
44
		/// The scores.
28
		/// The selected item.
45 29
		/// </value>
46
		private IDictionary<string, double> Scores { get; set; }
30
		public int SelectedItem { get; set; }
47 31
48 32
		/// <summary>
49
		/// Gets or sets the highlighted scores.
33
		/// Gets or sets the server.
50 34
		/// </summary>
51 35
		/// <value>
52
		/// The highlighted scores.
36
		/// The server.
53 37
		/// </value>
54
		private IList<string> HighlightedScores { get; set; }
38
		public Uri Server { get; set; }
55 39
56 40
		/// <summary>
57 41
		/// Gets the cache file.
@ -85,34 +69,50 @@ namespace pulse
85 69
		private int Commits { get; set; }
86 70
87 71
		/// <summary>
88
		/// Gets or sets the projects.
72
		/// Gets the height.
89 73
		/// </summary>
90 74
		/// <value>
91
		/// The projects.
75
		/// The height.
92 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 85
		/// <summary>
96
		/// Gets or sets the work items.
86
		/// Gets or sets the highlighted scores.
97 87
		/// </summary>
98 88
		/// <value>
99
		/// The work items.
89
		/// The highlighted scores.
100 90
		/// </value>
101
		private int WorkItems { get; set; }
91
		private IList<string> HighlightedScores { get; set; }
102 92
103 93
		/// <summary>
104
		/// Gets the height.
94
		/// Gets or sets the points.
105 95
		/// </summary>
106 96
		/// <value>
107
		/// The height.
97
		/// The points.
108 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 117
		/// <summary>
118 118
		/// Gets the width.
@ -128,6 +128,14 @@ namespace pulse
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 139
		/// <summary>
132 140
		/// Initializes a new instance of the <see cref="Dashboard" /> class.
133 141
		/// </summary>
@ -142,6 +150,20 @@ namespace pulse
142 150
			this.SelectedItem = 1;
143 151
			this.Scores = new Dictionary<string, double>();
144 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 168
			var cacheFile = new FileInfo(this.CacheFile);
147 169
@ -187,6 +209,20 @@ namespace pulse
187 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 226
								break;
191 227
						}
192 228
					}
@ -214,26 +250,26 @@ namespace pulse
214 250
				}
215 251
216 252
				// Get a point for participation.
217
				this.Scores[personOfInterest] += Rewards.Participation;
253
				this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
218 254
219 255
				// Handle points for commits with comments.
220 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 260
				else
225 261
				{
226
					this.Scores[personOfInterest] += Rewards.Verbosity;
262
					this.Scores[personOfInterest] += this.GetPoints(Rewards.Verbosity);
227 263
				}
228 264
229 265
				// Handle points with associating commits with actual work.
230 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 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,7 +312,7 @@ namespace pulse
276 312
						}
277 313
278 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 318
				else
@ -284,7 +320,7 @@ namespace pulse
284 320
					if (!string.IsNullOrWhiteSpace(item.CreatedBy))
285 321
					{
286 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,30 +334,30 @@ namespace pulse
298 334
					switch (item.Type.Name.ToLower())
299 335
					{
300 336
						case "product backlog item":
301
							this.Scores[personOfInterest] += Rewards.Participation;
337
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
302 338
							break;
303 339
304 340
						case "user story":
305
							this.Scores[personOfInterest] += Rewards.Participation;
341
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
306 342
							break;
307 343
308 344
						case "feature":
309
							this.Scores[personOfInterest] += Rewards.Participation;
345
							this.Scores[personOfInterest] += this.GetPoints(Rewards.Participation);
310 346
							break;
311 347
312 348
						case "task":
313
							this.Scores[personOfInterest] += Rewards.CreatedWork;
349
							this.Scores[personOfInterest] += this.GetPoints(Rewards.CreatedWork);
314 350
							break;
315 351
316 352
						case "impediment":
317 353
						case "issue":
318 354
						case "bug":
319
							this.Scores[personOfInterest] += Rewards.BugReport;
355
							this.Scores[personOfInterest] += this.GetPoints(Rewards.BugReport);
320 356
							break;
321 357
322 358
						case "test case":
323 359
						case "shared steps":
324
							this.Scores[personOfInterest] += Rewards.CreatedWork;
360
							this.Scores[personOfInterest] += this.GetPoints(Rewards.CreatedWork);
325 361
							break;
326 362
327 363
						default:
@ -338,18 +374,18 @@ namespace pulse
338 374
						case "approved":
339 375
						case "active":
340 376
						case "in progress":
341
							this.Scores[personOfInterest] += Rewards.TakingOwnership;
377
							this.Scores[personOfInterest] += this.GetPoints(Rewards.TakingOwnership);
342 378
							break;
343 379
344 380
						case "done":
345 381
						case "committed":
346 382
						case "resolved":
347 383
						case "closed":
348
							this.Scores[personOfInterest] += Rewards.FinishWork;
384
							this.Scores[personOfInterest] += this.GetPoints(Rewards.FinishWork);
349 385
							break;
350 386
351 387
						case "removed":
352
							this.Scores[personOfInterest] += Rewards.HouseCleaning;
388
							this.Scores[personOfInterest] += this.GetPoints(Rewards.HouseCleaning);
353 389
							break;
354 390
355 391
						default:
@ -378,6 +414,11 @@ namespace pulse
378 414
				{
379 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,6 +522,21 @@ namespace pulse
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 540
		/// <summary>
485 541
		/// Statisticses this instance.
486 542
		/// </summary>

+ 2 - 2
Penalties.cs

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

+ 18 - 18
Rewards.cs

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