Merge pull request #1371 from dampir/add-repo-id-statistics-client

Add repositoryId overloads to methods on I(Observable)StatisticsClient
This commit is contained in:
Brendan Forster
2016-07-07 10:09:53 +10:00
committed by GitHub
7 changed files with 969 additions and 175 deletions
@@ -3,46 +3,77 @@ using System.Collections.Generic;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Repository Statistics API.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/statistics/">Repository Statistics API documentation</a> for more information.
/// </remarks>
public interface IObservableStatisticsClient
{
/// <summary>
/// Returns a list of <see cref="Contributor"/> for the given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>A list of <see cref="Contributor"/></returns>
IObservable<IEnumerable<Contributor>> GetContributors(string owner, string repositoryName);
/// <param name="name">The name of the repository</param>
IObservable<IEnumerable<Contributor>> GetContributors(string owner, string name);
/// <summary>
/// Returns a list of <see cref="Contributor"/> for the given repository
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
IObservable<IEnumerable<Contributor>> GetContributors(int repositoryId);
/// <summary>
/// Returns the last year of commit activity grouped by week.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>The last year of <see cref="CommitActivity"/></returns>
IObservable<CommitActivity> GetCommitActivity(string owner, string repositoryName);
/// <param name="name">The name of the repository</param>
IObservable<CommitActivity> GetCommitActivity(string owner, string name);
/// <summary>
/// Returns the last year of commit activity grouped by week.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
IObservable<CommitActivity> GetCommitActivity(int repositoryId);
/// <summary>
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns a weekly aggregate of the number additions and deletion</returns>
IObservable<CodeFrequency> GetCodeFrequency(string owner, string repositoryName);
/// <param name="name">The name of the repository</param>
IObservable<CodeFrequency> GetCodeFrequency(string owner, string name);
/// <summary>
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
IObservable<CodeFrequency> GetCodeFrequency(int repositoryId);
/// <summary>
/// Returns the total commit counts for the owner and total commit counts in total.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
IObservable<Participation> GetParticipation(string owner, string repositoryName);
/// <param name="name">The name of the repository</param>
IObservable<Participation> GetParticipation(string owner, string name);
/// <summary>
/// Returns the total commit counts for the owner and total commit counts in total.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
IObservable<Participation> GetParticipation(int repositoryId);
/// <summary>
/// Returns a list of the number of commits per hour in each day
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns commit counts per hour in each day</returns>
IObservable<PunchCard> GetPunchCard(string owner, string repositoryName);
/// <param name="name">The name of the repository</param>
IObservable<PunchCard> GetPunchCard(string owner, string name);
/// <summary>
/// Returns a list of the number of commits per hour in each day
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
IObservable<PunchCard> GetPunchCard(int repositoryId);
}
}
@@ -4,6 +4,12 @@ using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Repository Statistics API.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/statistics/">Repository Statistics API documentation</a> for more information.
/// </remarks>
public class ObservableStatisticsClient : IObservableStatisticsClient
{
readonly IGitHubClient _client;
@@ -11,6 +17,7 @@ namespace Octokit.Reactive
public ObservableStatisticsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client;
}
@@ -18,70 +25,110 @@ namespace Octokit.Reactive
/// Returns a list of <see cref="Contributor"/> for the given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>A list of <see cref="Contributor"/></returns>
public IObservable<IEnumerable<Contributor>> GetContributors(string owner, string repositoryName)
/// <param name="name">The name of the repository</param>
public IObservable<IEnumerable<Contributor>> GetContributors(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Repository.Statistics.GetContributors(owner, repositoryName).ToObservable();
return _client.Repository.Statistics.GetContributors(owner, name).ToObservable();
}
/// <summary>
/// Returns a list of <see cref="Contributor"/> for the given repository
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
public IObservable<IEnumerable<Contributor>> GetContributors(int repositoryId)
{
return _client.Repository.Statistics.GetContributors(repositoryId).ToObservable();
}
/// <summary>
/// Returns the last year of commit activity grouped by week.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>The last year of <see cref="CommitActivity"/></returns>
public IObservable<CommitActivity> GetCommitActivity(string owner, string repositoryName)
/// <param name="name">The name of the repository</param>
public IObservable<CommitActivity> GetCommitActivity(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Repository.Statistics.GetCommitActivity(owner, repositoryName).ToObservable();
return _client.Repository.Statistics.GetCommitActivity(owner, name).ToObservable();
}
/// <summary>
/// Returns the last year of commit activity grouped by week.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
public IObservable<CommitActivity> GetCommitActivity(int repositoryId)
{
return _client.Repository.Statistics.GetCommitActivity(repositoryId).ToObservable();
}
/// <summary>
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns a weekly aggregate of the number additions and deletion</returns>
public IObservable<CodeFrequency> GetCodeFrequency(string owner, string repositoryName)
/// <param name="name">The name of the repository</param>
public IObservable<CodeFrequency> GetCodeFrequency(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Repository.Statistics.GetCodeFrequency(owner, repositoryName).ToObservable();
return _client.Repository.Statistics.GetCodeFrequency(owner, name).ToObservable();
}
/// <summary>
/// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
public IObservable<CodeFrequency> GetCodeFrequency(int repositoryId)
{
return _client.Repository.Statistics.GetCodeFrequency(repositoryId).ToObservable();
}
/// <summary>
/// Returns the total commit counts for the owner and total commit counts in total.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
public IObservable<Participation> GetParticipation(string owner, string repositoryName)
/// <param name="name">The name of the repository</param>
public IObservable<Participation> GetParticipation(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Repository.Statistics.GetParticipation(owner, repositoryName).ToObservable();
return _client.Repository.Statistics.GetParticipation(owner, name).ToObservable();
}
/// <summary>
/// Returns the total commit counts for the owner and total commit counts in total.
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
public IObservable<Participation> GetParticipation(int repositoryId)
{
return _client.Repository.Statistics.GetParticipation(repositoryId).ToObservable();
}
/// <summary>
/// Returns a list of the number of commits per hour in each day
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="repositoryName">The name of the repository</param>
/// <returns>Returns commit counts per hour in each day</returns>
public IObservable<PunchCard> GetPunchCard(string owner, string repositoryName)
/// <param name="name">The name of the repository</param>
public IObservable<PunchCard> GetPunchCard(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.Repository.Statistics.GetPunchCard(owner, repositoryName).ToObservable();
return _client.Repository.Statistics.GetPunchCard(owner, name).ToObservable();
}
/// <summary>
/// Returns a list of the number of commits per hour in each day
/// </summary>
/// <param name="repositoryId">The ID of the repository</param>
public IObservable<PunchCard> GetPunchCard(int repositoryId)
{
return _client.Repository.Statistics.GetPunchCard(repositoryId).ToObservable();
}
}
}
}