mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
145 lines
6.3 KiB
C#
145 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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;
|
|
|
|
public ObservableStatisticsClient(IGitHubClient client)
|
|
{
|
|
Ensure.ArgumentNotNull(client, "client");
|
|
|
|
_client = client;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a list of <see cref="Contributor"/> for the given repository
|
|
/// </summary>
|
|
/// <param name="owner">The owner of the repository</param>
|
|
/// <param name="name">The name of the repository</param>
|
|
/// <returns>A list of <see cref="Contributor"/></returns>
|
|
public IObservable<IEnumerable<Contributor>> GetContributors(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
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>
|
|
/// <returns>A list of <see cref="Contributor"/></returns>
|
|
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="name">The name of the repository</param>
|
|
/// <returns>The last year of <see cref="CommitActivity"/></returns>
|
|
public IObservable<CommitActivity> GetCommitActivity(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
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>
|
|
/// <returns>The last year of <see cref="CommitActivity"/></returns>
|
|
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="name">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 name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
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>
|
|
/// <returns>Returns a weekly aggregate of the number additions and deletion</returns>
|
|
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="name">The name of the repository</param>
|
|
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
|
public IObservable<Participation> GetParticipation(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
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>
|
|
/// <returns>Returns <see cref="Participation"/>from oldest week to now</returns>
|
|
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="name">The name of the repository</param>
|
|
/// <returns>Returns commit counts per hour in each day</returns>
|
|
public IObservable<PunchCard> GetPunchCard(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
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>
|
|
/// <returns>Returns commit counts per hour in each day</returns>
|
|
public IObservable<PunchCard> GetPunchCard(int repositoryId)
|
|
{
|
|
return _client.Repository.Statistics.GetPunchCard(repositoryId).ToObservable();
|
|
}
|
|
}
|
|
}
|