mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
Line up with the api - what is this all about
💄
This commit is contained in:
@@ -62,11 +62,11 @@ namespace Octokit.Tests.Integration.Clients
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetCommitCountsPerWeek()
|
||||
public async Task CanGetParticipationStatistics()
|
||||
{
|
||||
var repository = await CreateRepository();
|
||||
await CommitToRepository(repository);
|
||||
var weeklyCommitCounts = await _client.Statistics.GetCommitCountsPerWeek(repository.Owner, repository.Name);
|
||||
var weeklyCommitCounts = await _client.Statistics.GetParticipation(repository.Owner, repository.Name);
|
||||
Assert.NotNull(weeklyCommitCounts);
|
||||
Assert.NotNull(weeklyCommitCounts.All);
|
||||
Assert.NotNull(weeklyCommitCounts.Owner);
|
||||
|
||||
@@ -118,23 +118,23 @@ namespace Octokit.Tests.Clients
|
||||
var client = Substitute.For<IApiConnection>();
|
||||
var statisticsClient = new StatisticsClient(client);
|
||||
|
||||
statisticsClient.GetCommitCountsPerWeek("username", "repositoryName");
|
||||
statisticsClient.GetParticipation("username", "repositoryName");
|
||||
|
||||
client.Received().GetQueuedOperation<WeeklyCommitCounts>(expectedEndPoint, Args.CancellationToken);
|
||||
client.Received().GetQueuedOperation<Participation>(expectedEndPoint, Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsIfGivenNullOwner()
|
||||
{
|
||||
var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
|
||||
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetCommitCountsPerWeek(null, "repositoryName"));
|
||||
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetParticipation(null, "repositoryName"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsIfGivenNullRepositoryName()
|
||||
{
|
||||
var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
|
||||
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetCommitCountsPerWeek("owner", null));
|
||||
await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetParticipation("owner", null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <returns>Returns <see cref="WeeklyCommitCounts"/>from oldest week to now</returns>
|
||||
Task<WeeklyCommitCounts> GetCommitCountsPerWeek(string owner, string repositoryName);
|
||||
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
||||
Task<Participation> GetParticipation(string owner, string repositoryName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the total commit counts for the owner and total commit counts in total.
|
||||
@@ -72,8 +72,8 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
|
||||
/// <returns>Returns <see cref="WeeklyCommitCounts"/>from oldest week to now</returns>
|
||||
Task<WeeklyCommitCounts> GetCommitCountsPerWeek(string owner, string repositoryName, CancellationToken cancellationToken);
|
||||
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
||||
Task<Participation> GetParticipation(string owner, string repositoryName, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of the number of commits per hour in each day
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <returns>Returns <see cref="WeeklyCommitCounts"/>from oldest week to now</returns>
|
||||
public Task<WeeklyCommitCounts> GetCommitCountsPerWeek(string owner, string repositoryName)
|
||||
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
||||
public Task<Participation> GetParticipation(string owner, string repositoryName)
|
||||
{
|
||||
return GetCommitCountsPerWeek(owner, repositoryName, CancellationToken.None);
|
||||
return GetParticipation(owner, repositoryName, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,14 +113,14 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
|
||||
/// <returns>Returns <see cref="WeeklyCommitCounts"/>from oldest week to now</returns>
|
||||
public async Task<WeeklyCommitCounts> GetCommitCountsPerWeek(string owner, string repositoryName, CancellationToken cancellationToken)
|
||||
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
||||
public async Task<Participation> GetParticipation(string owner, string repositoryName, CancellationToken cancellationToken)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
var endpoint = "/repos/{0}/{1}/stats/participation".FormatUri(owner, repositoryName);
|
||||
return await ApiConnection.GetQueuedOperation<WeeklyCommitCounts>(endpoint,cancellationToken);
|
||||
return await ApiConnection.GetQueuedOperation<Participation>(endpoint,cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the total commit counts for the owner and total commit counts in total in the last 52 weeks
|
||||
/// </summary>
|
||||
public class Participation
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the commit counts made each week, for the last 52 weeks
|
||||
/// </summary>
|
||||
public IEnumerable<int> All { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the commit counts made by the owner each week, for the last 52 weeks
|
||||
/// </summary>
|
||||
public IEnumerable<int> Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of commits made by the owner in the last 52 weeks.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int TotalCommitsByOwner()
|
||||
{
|
||||
return Owner.Sum();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total number of commits made by contributors in the last 52 weeks.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int TotalCommitsByContributors()
|
||||
{
|
||||
return All.Sum() - Owner.Sum();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total number of commits made in the last 52 weeks.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int TotalCommits()
|
||||
{
|
||||
return All.Sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class WeeklyCommitCounts
|
||||
{
|
||||
public IEnumerable<int> All { get; set; }
|
||||
|
||||
public IEnumerable<int> Owner { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,6 @@
|
||||
<Compile Include="Models\Response\TreeResponse.cs" />
|
||||
<Compile Include="Models\Response\Team.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitCounts.cs" />
|
||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Exceptions\TwoFactorChallengeFailedException.cs" />
|
||||
@@ -275,6 +274,7 @@
|
||||
<Compile Include="Models\Request\ReleaseAssetUpdate.cs" />
|
||||
<Compile Include="Models\Response\PunchCard.cs" />
|
||||
<Compile Include="Models\Response\PunchCardPoint.cs" />
|
||||
<Compile Include="Models\Response\Participation.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -281,10 +281,10 @@
|
||||
<Compile Include="Models\Response\Author.cs" />
|
||||
<Compile Include="Models\Response\Contributor.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitCounts.cs" />
|
||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||
<Compile Include="Models\Response\PunchCard.cs" />
|
||||
<Compile Include="Models\Response\PunchCardPoint.cs" />
|
||||
<Compile Include="Models\Response\Participation.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -276,10 +276,10 @@
|
||||
<Compile Include="Models\Response\Author.cs" />
|
||||
<Compile Include="Models\Response\Contributor.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitCounts.cs" />
|
||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||
<Compile Include="Models\Response\PunchCard.cs" />
|
||||
<Compile Include="Models\Response\PunchCardPoint.cs" />
|
||||
<Compile Include="Models\Response\Participation.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -239,7 +239,6 @@
|
||||
<Compile Include="Models\Response\Team.cs" />
|
||||
<Compile Include="Models\Response\User.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitCounts.cs" />
|
||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\StringExtensions.cs" />
|
||||
@@ -273,6 +272,7 @@
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
<Compile Include="Models\Response\PunchCard.cs" />
|
||||
<Compile Include="Models\Response\PunchCardPoint.cs" />
|
||||
<Compile Include="Models\Response\Participation.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
<Compile Include="Models\Response\Signature.cs" />
|
||||
<Compile Include="Models\Response\TagObject.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||
<Compile Include="Models\Response\WeeklyCommitCounts.cs" />
|
||||
<Compile Include="Models\Response\Participation.cs" />
|
||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Exceptions\TwoFactorChallengeFailedException.cs" />
|
||||
|
||||
Reference in New Issue
Block a user