Permalink
Browse files

Noodling

  • Loading branch information...
1 parent f6e0edc commit ef2a1dd7fb738bd520e888784db9181aeca61350 @drunkcod drunkcod committed Mar 22, 2011
@@ -94,6 +94,8 @@
<Content Include="Content\PivotalTracker\chore.png" />
<Content Include="Content\PivotalTracker\feature.png" />
<Content Include="Content\Style.css" />
+ <Content Include="TeamNorthBurndown.txt" />
+ <Content Include="TeamIncrediblesBurndown.txt" />
<Content Include="Global.asax" />
<Content Include="TeamSouthBurndown.txt" />
<Content Include="Views\Badges\Index.aspx" />
@@ -8,26 +8,22 @@
namespace CardWall.Controllers
{
+ class BurndownChartConfiguration
+ {
+ public string Name;
+ public string Label;
+ public int Project;
+ public string HistoricalDataPath;
+ }
+
public class ChartsController : Controller
{
public ActionResult Index(string team) {
var burndownColor = Color.SteelBlue;
- var title = string.Empty;
- switch(team) {
- case "team north":
- title = "Team North";
- break;
- case "incredible":
- title = "Team Incredibles";
- break;
- default:
- team = "team south";
- title = "Team South";
- break;
- }
-
- var burndown = GetSouthBurndownData(team);
+ var configuration = GetConfiguration(team);
+
+ var burndown = GetSouthBurndownData(configuration.Project, configuration.Label, configuration.HistoricalDataPath);
var startDate = burndown.Min(item => item.Date);
var endDate = new DateTime(2011, 6, 1);
@@ -53,29 +49,54 @@ public class ChartsController : Controller
ChartMarker.NewCircle(burndownColor, 0, -1, 8),
ChartMarker.NewCircle(Color.White, 0, -1, 4)
}, LineChartMode.XY, encoding, new[]{ LineStyle.Default, LineStyle.NewDashed(2, 2, 4) });
- return View(new ChartView { Name = title, DisplayMarkup = "<img src='" + chart.ToString() + "'/>" });
+ return View(new ChartView { Name = configuration.Name, DisplayMarkup = "<img src='" + chart.ToString() + "'/>" });
}
- BurndownData GetSouthBurndownData(string label)
+ BurndownData GetSouthBurndownData(int project, string label, string historicalDataPath)
{
var tracker = new PivotalTracker(Environment.GetEnvironmentVariable("TrackerToken", EnvironmentVariableTarget.Machine));
var stories =
- tracker.Stories(173053).Result
+ tracker.Stories(project).Result
.Where(item => item.Labels.Contains(label, StringComparer.InvariantCultureIgnoreCase))
.Where(item => item.CurrentState != PivotalStoryState.Accepted);
var pointsRemaining = stories.Sum(item => Math.Max(0, item.Estimate ?? 0));
- return new BurndownData(LoadBurndownData(Server.MapPath("TeamSouthBurndown.txt"))){
+ return new BurndownData(LoadBurndownData(Server.MapPath(historicalDataPath))){
{ DateTime.Today, pointsRemaining }
};
}
+ BurndownChartConfiguration GetConfiguration(string team) {
+ switch(team) {
+ case "team north":
+ return new BurndownChartConfiguration {
+ Name = "Team North",
+ Project = 173053,
+ Label = team,
+ HistoricalDataPath = "TeamNorthBurndown.txt"
+ };
+ case "incredible":
+ return new BurndownChartConfiguration {
+ Name = "Team Incredibles",
+ Project = 173053,
+ Label = team,
+ HistoricalDataPath = "TeamIncrediblesBurndown.txt"
+ };
+ default:
+ return new BurndownChartConfiguration {
+ Name = "Team South",
+ Project = 173053,
+ Label = "team south",
+ HistoricalDataPath = "TeamSouthBurndown.txt"
+ };
+ }
+ }
+
IEnumerable<BurndownDataPoint> LoadBurndownData(string path) {
using(var input = new StreamReader(System.IO.File.OpenRead(path))) {
for(string line; (line = input.ReadLine()) != null;) {
- var parts = line.Split(';');
- yield return new BurndownDataPoint(DateTime.Parse(parts[0]), int.Parse(parts[1]));
+ yield return BurndownDataPoint.Parse(line);
}
}
}
@@ -1,15 +1,27 @@
using System;
+using System.Text.RegularExpressions;
+using System.Globalization;
namespace CardWall.Models
{
public struct BurndownDataPoint
{
+ const char Separator = ';';
public readonly DateTime Date;
public readonly int PointsRemaining;
public BurndownDataPoint(DateTime date, int pointsRemaining) {
this.Date = date;
this.PointsRemaining = pointsRemaining;
}
+
+ public override string ToString() {
+ return string.Format("{0}{1}{2}", Date.ToShortDateString(), Separator, PointsRemaining);
+ }
+
+ public static BurndownDataPoint Parse(string input) {
+ var parts = input.Split(new[]{ Separator }, StringSplitOptions.RemoveEmptyEntries);
+ return new BurndownDataPoint(DateTime.Parse(parts[0], CultureInfo.InvariantCulture), int.Parse(parts[1]));
+ }
}
}
@@ -0,0 +1 @@
+
@@ -0,0 +1 @@
+
@@ -50,8 +50,13 @@
<Compile Include="GoogleChartWriterSpec.cs" />
<Compile Include="PivotalStorySpec.cs" />
<Compile Include="PivotalTaskSpec.cs" />
+ <Compile Include="Site\Models\BurndownDataPointSpec.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Site\CardWall.Site.csproj">
+ <Project>{D5ED8D7F-614E-4E8E-9073-3D5AAAAD58F7}</Project>
+ <Name>CardWall.Site</Name>
+ </ProjectReference>
<ProjectReference Include="..\Source\CardWall.Core.fsproj">
<Project>{DEC7E915-245A-4F62-8C70-A4582ADCD25C}</Project>
<Name>CardWall.Core</Name>
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Cone;
+using CardWall.Models;
+
+namespace CardWall.Specs.Site.Models
+{
+ [Describe(typeof(BurndownDataPoint))]
+ public class BurndownDataPointSpec
+ {
+ public void parsing_roundtrip() {
+ var original = new BurndownDataPoint(new DateTime(1976, 8, 27), 42);
+ var clone = BurndownDataPoint.Parse(original.ToString());
+
+ Verify.That(() => clone.Date == original.Date);
+ Verify.That(() => clone.PointsRemaining == original.PointsRemaining);
+
+ }
+ }
+}

0 comments on commit ef2a1dd

Please sign in to comment.