-
Community GitHub Contributions
+
GitHub Contributions
Contributions to Umbraco GitHub repositories
diff --git a/OurUmbraco.Site/Views/Partials/Home/GitHubContributors.cshtml b/OurUmbraco.Site/Views/Partials/Home/GitHubContributors.cshtml
index ede70422..5db11f31 100644
--- a/OurUmbraco.Site/Views/Partials/Home/GitHubContributors.cshtml
+++ b/OurUmbraco.Site/Views/Partials/Home/GitHubContributors.cshtml
@@ -4,13 +4,17 @@
{
foreach (var contributor in Model.Contributors)
{
- var author = contributor.First().Author;
+ var author = contributor.Author;
if (author != null)
{

-
@contributor.Sum(x => x.Total)
+
@contributor.TotalCommits
+
+ Additions: @contributor.TotalAdditions
+
Deletions: @contributor.TotalDeletions
+
}
diff --git a/OurUmbraco/Community/Controllers/GitHubContributorController.cs b/OurUmbraco/Community/Controllers/GitHubContributorController.cs
index 6eeb4207..4f6d86ea 100644
--- a/OurUmbraco/Community/Controllers/GitHubContributorController.cs
+++ b/OurUmbraco/Community/Controllers/GitHubContributorController.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
-using System.Web.Http;
using System.Web.Mvc;
using OurUmbraco.Community.Models;
using OurUmbraco.Our.Api;
@@ -16,7 +15,7 @@ namespace OurUmbraco.Community.Controllers
public class GitHubContributorController : SurfaceController
{
///
- /// Repositories to include in the combination
+ /// Repositories to include in the combination of contributions
///
private readonly string[] Repositories =
{
@@ -44,9 +43,9 @@ namespace OurUmbraco.Community.Controllers
LogHelper.Debug("Config file was not found: " + configPath);
return PartialView("~/Views/Partials/Home/GitHubContributors.cshtml", model);
}
-
+
string[] login = System.IO.File.ReadAllLines(configPath).Where(x => x.Trim() != "").Distinct().ToArray();
- var contributors = ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem>("UmbracoGitHubContributors",
+ var contributors = ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem>("UmbracoGitHubContributors",
() =>
{
var githubController = new GitHubController();
@@ -64,16 +63,25 @@ namespace OurUmbraco.Community.Controllers
LogHelper.Warn(string.Format("Invalid HTTP response for repository {0}", repo));
}
}
- return gitHubContributors;
+
+ var filteredContributors = gitHubContributors
+ .Where(g => !login.Contains(g.Author.Login))
+ .GroupBy(g => g.Author.Id)
+ .OrderByDescending(c => c.Sum(g => g.Total));
+
+ List temp = new List();
+
+ foreach (var group in filteredContributors)
+ {
+ temp.Add(new GitHubGlobalContributorModel(group));
+ }
+
+ return temp;
}, TimeSpan.FromDays(1));
- var filteredContributors = contributors
- .Where(g => !login.Contains(g.Author.Login))
- .GroupBy(g => g.Author.Id)
- .OrderByDescending(c => c.Sum(g => g.Total));
- model.Contributors = filteredContributors;
+ model.Contributors = contributors;
}
catch (Exception ex)
{
diff --git a/OurUmbraco/Community/Controllers/GitHubGlobalContributorModel.cs b/OurUmbraco/Community/Controllers/GitHubGlobalContributorModel.cs
new file mode 100644
index 00000000..a5766ed3
--- /dev/null
+++ b/OurUmbraco/Community/Controllers/GitHubGlobalContributorModel.cs
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+using System.Linq;
+using OurUmbraco.Community.Models;
+
+namespace OurUmbraco.Community.Controllers
+{
+ public class GitHubGlobalContributorModel
+ {
+ public List Items { get; set; }
+
+ public int Id
+ {
+ get { return Author.Id; }
+ }
+
+ public int TotalCommits
+ {
+ get { return Items.Sum(x => x.Total); }
+ }
+
+ public int TotalAdditions
+ {
+ get { return Items.Sum(x => x.TotalAdditions); }
+ }
+
+ public int TotalDeletions
+ {
+ get { return Items.Sum(x => x.TotalDeletions); }
+ }
+
+ public Author Author
+ {
+ get { return Items.First().Author; }
+ }
+
+ public GitHubGlobalContributorModel(IEnumerable items)
+ {
+ Items = items.ToList();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/OurUmbraco/Community/Models/GitHubContributorsModel.cs b/OurUmbraco/Community/Models/GitHubContributorsModel.cs
index 51f04a6b..592a5524 100644
--- a/OurUmbraco/Community/Models/GitHubContributorsModel.cs
+++ b/OurUmbraco/Community/Models/GitHubContributorsModel.cs
@@ -1,10 +1,10 @@
using System.Collections.Generic;
-using System.Linq;
+using OurUmbraco.Community.Controllers;
namespace OurUmbraco.Community.Models
{
public class GitHubContributorsModel : IGitHubContributorsModel
{
- public IEnumerable> Contributors { get; set; }
+ public List Contributors { get; set; }
}
}
\ No newline at end of file
diff --git a/OurUmbraco/Community/Models/GithubContributorModel.cs b/OurUmbraco/Community/Models/GithubContributorModel.cs
index 8a4c7054..3180b06e 100644
--- a/OurUmbraco/Community/Models/GithubContributorModel.cs
+++ b/OurUmbraco/Community/Models/GithubContributorModel.cs
@@ -6,25 +6,62 @@ namespace OurUmbraco.Community.Models
[DataContract]
public class GitHubContributorModel : IGitHubContributorModel
{
+
+ private List _weeks;
+
public int Total { get; set; }
- public List Weeks { get; set; }
+ public int TotalAdditions { get; set; }
+ public int TotalDeletions { get; set; }
+
+ [DataMember(Name = "weeks")]
+ public List Weeks
+ {
+ get { return _weeks; }
+
+ set
+ {
+ _weeks = value;
+
+
+ int totalAdditions = 0;
+ int totalDeletions = 0;
+ foreach (var week in _weeks)
+ {
+ totalDeletions += week.D;
+ totalAdditions += week.A;
+ }
+
+ TotalAdditions = totalAdditions;
+ TotalDeletions = totalDeletions;
+
+ }
+
+ }
public Author Author { get; set; }
}
[DataContract]
public class Week
{
- [DataMember(Name = "w")]
- public int Timestamp { get; set; }
+ ///
+ /// Timestamp
+ ///
+ public int W { get; set; }
- [DataMember(Name = "a")]
- public int Additions { get; set; }
+ ///
+ /// Additions
+ ///
+ public int A { get; set; }
- [DataMember(Name = "d")]
- public int Deletions { get; set; }
+ ///
+ /// Deletions
+ ///
+ public int D { get; set; }
- [DataMember(Name = "c")]
- public int Commits { get; set; }
+ ///
+ /// Commits
+ ///
+ public int C { get; set; }
}
[DataContract]