Updated model to use new method call with accurate commit information
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
@model OurUmbraco.Community.Models.GitHubContributorsModel
|
||||
|
||||
@foreach (var contributor in Model.Contributors)
|
||||
@if (Model.Contributors.Any())
|
||||
{
|
||||
<a href="@contributor.HtmlUrl" class="contributor" target="_blank">
|
||||
<div class="avatar">
|
||||
<img alt="@contributor.Login" src="@contributor.AvatarUrl" title="@contributor.Login" />
|
||||
<span class="contrib-count" title="@(contributor.Contributions + " contributions")">@contributor.Contributions</span>
|
||||
</div>
|
||||
</a>
|
||||
foreach (var contributor in Model.Contributors)
|
||||
{
|
||||
var author = contributor.Author;
|
||||
if (author != null)
|
||||
{
|
||||
<a href="@author.HtmlUrl" class="contributor" target="_blank">
|
||||
<div class="avatar">
|
||||
<img alt="@author.Login" src="@author.AvatarUrl" title="@author.Login" />
|
||||
<span class="contrib-count" title="@(contributor.Total + " contributions")">@contributor.Total</span>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.Contributors.Any() == false)
|
||||
else
|
||||
{
|
||||
<h2>Could not load recent GitHub contributors.</h2>
|
||||
}
|
||||
@@ -22,7 +22,6 @@ namespace OurUmbraco.Community.Controllers
|
||||
var contributors = ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem<List<GitHubContributorModel>>("UmbracoGitHubContributors",
|
||||
() =>
|
||||
{
|
||||
//TODO: GitHub keys if required
|
||||
var githubController = new GitHubController();
|
||||
var response = githubController.GetAllContributors();
|
||||
if (response.StatusCode == HttpStatusCode.OK && response.ResponseStatus == ResponseStatus.Completed)
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace OurUmbraco.Community.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class GitHubContributorModel : IGitHubContributorModel
|
||||
{
|
||||
public int Total { get; set; }
|
||||
public List<Week> Weeks { get; set; }
|
||||
public Author Author { get; set; }
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class Week
|
||||
{
|
||||
[DataMember(Name = "w")]
|
||||
public int Timestamp { get; set; }
|
||||
|
||||
[DataMember(Name = "a")]
|
||||
public int Additions { get; set; }
|
||||
|
||||
[DataMember(Name = "d")]
|
||||
public int Deletions { get; set; }
|
||||
|
||||
[DataMember(Name = "c")]
|
||||
public int Commits { get; set; }
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class Author
|
||||
{
|
||||
public string Login { get; set; }
|
||||
|
||||
@@ -51,7 +76,5 @@ namespace OurUmbraco.Community.Models
|
||||
|
||||
[DataMember(Name = "site_admin")]
|
||||
public bool SiteAdmin { get; set; }
|
||||
|
||||
public int Contributions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,8 @@ namespace OurUmbraco.Our.Api
|
||||
/// <returns></returns>
|
||||
public IRestResponse<List<GitHubContributorModel>> GetAllContributors()
|
||||
{
|
||||
//https://api.github.com/repos/umbraco/Umbraco-CMS/contributors
|
||||
var client = new RestClient("https://api.github.com");
|
||||
var request = new RestRequest("/repos/umbraco/Umbraco-CMS/contributors", Method.GET);
|
||||
var request = new RestRequest("/repos/umbraco/Umbraco-CMS/stats/contributors", Method.GET);
|
||||
client.UserAgent = "OurUmbraco";
|
||||
|
||||
var response = client.Execute<List<GitHubContributorModel>>(request);
|
||||
|
||||
Reference in New Issue
Block a user