Last active
August 29, 2015 14:16
-
-
Save joshrobb/4430c2d286f5ee77db9e to your computer and use it in GitHub Desktop.
Team Stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var github = new GitHubClient(new ProductHeaderValue("PushpayTech")); | |
var tokenAuth = new Credentials("XXX"); | |
github.Credentials = tokenAuth; | |
var releases = await github.Release.GetAll("pushpay","pushpay"); | |
var prfilter = new PullRequestRequest { | |
State = ItemState.All | |
}; | |
var prs = await github.Repository.PullRequest.GetForRepository("pushpay","pushpay",prfilter); | |
var cal = CultureInfo.InvariantCulture.Calendar; | |
var created = prs.GroupBy (p => new{p.CreatedAt.Year, week = cal.GetWeekOfYear(p.CreatedAt.DateTime,CalendarWeekRule.FirstDay,DayOfWeek.Monday)}) | |
.Select (p => new {period = p.Key.Year + p.Key.week.ToString("D2"), count = p.Count ()} ); | |
var merged = prs.Where (p => p.MergedAt.HasValue ) | |
.GroupBy (p => new{p.MergedAt.Value.Year, week = cal.GetWeekOfYear(p.MergedAt.Value.DateTime,CalendarWeekRule.FirstDay,DayOfWeek.Monday)}) | |
.Select (p => new {period = p.Key.Year + p.Key.week.ToString("D2"), count = p.Count ()} ); | |
var released = releases.GroupBy (p => new{p.CreatedAt.Year, week = cal.GetWeekOfYear(p.CreatedAt.DateTime,CalendarWeekRule.FirstDay,DayOfWeek.Monday)}) | |
.Select (p => new {period = p.Key.Year + p.Key.week.ToString("D2"), test = p.Count (r => r.TagName.StartsWith("Test")), prod = p.Count (x =>x.TagName.StartsWith("Production") )} ); | |
var rolledup = from c in created | |
join m in merged on c.period equals m.period | |
join r in released on c.period equals r.period | |
select new {c.period,created= c.count,merged = m.count, r.test, r.prod}; | |
rolledup.Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment