From dcac7b9305c8ae7827a3b3b57a6fd99a2bd4f960 Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Mon, 13 Jun 2016 12:05:05 +0700 Subject: [PATCH] added new overloads --- .../Clients/IObservableStatisticsClient.cs | 35 +++++ .../Clients/ObservableStatisticsClient.cs | 53 +++++++- Octokit/Clients/IStatisticsClient.cs | 75 ++++++++++ Octokit/Clients/StatisticsClient.cs | 128 ++++++++++++++++++ 4 files changed, 290 insertions(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/IObservableStatisticsClient.cs b/Octokit.Reactive/Clients/IObservableStatisticsClient.cs index 7261b3d1..ec81cf82 100644 --- a/Octokit.Reactive/Clients/IObservableStatisticsClient.cs +++ b/Octokit.Reactive/Clients/IObservableStatisticsClient.cs @@ -19,6 +19,13 @@ namespace Octokit.Reactive /// A list of IObservable> GetContributors(string owner, string name); + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A list of + IObservable> GetContributors(int repositoryId); + /// /// Returns the last year of commit activity grouped by week. /// @@ -27,6 +34,13 @@ namespace Octokit.Reactive /// The last year of IObservable GetCommitActivity(string owner, string name); + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// The last year of + IObservable GetCommitActivity(int repositoryId); + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -35,6 +49,13 @@ namespace Octokit.Reactive /// Returns a weekly aggregate of the number additions and deletion IObservable GetCodeFrequency(string owner, string name); + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// Returns a weekly aggregate of the number additions and deletion + IObservable GetCodeFrequency(int repositoryId); + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -43,6 +64,13 @@ namespace Octokit.Reactive /// Returns from oldest week to now IObservable GetParticipation(string owner, string name); + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// Returns from oldest week to now + IObservable GetParticipation(int repositoryId); + /// /// Returns a list of the number of commits per hour in each day /// @@ -50,5 +78,12 @@ namespace Octokit.Reactive /// The name of the repository /// Returns commit counts per hour in each day IObservable GetPunchCard(string owner, string name); + + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// Returns commit counts per hour in each day + IObservable GetPunchCard(int repositoryId); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableStatisticsClient.cs b/Octokit.Reactive/Clients/ObservableStatisticsClient.cs index 16a67d9d..76e5913a 100644 --- a/Octokit.Reactive/Clients/ObservableStatisticsClient.cs +++ b/Octokit.Reactive/Clients/ObservableStatisticsClient.cs @@ -17,6 +17,7 @@ namespace Octokit.Reactive public ObservableStatisticsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); + _client = client; } @@ -34,6 +35,16 @@ namespace Octokit.Reactive return _client.Repository.Statistics.GetContributors(owner, name).ToObservable(); } + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A list of + public IObservable> GetContributors(int repositoryId) + { + return _client.Repository.Statistics.GetContributors(repositoryId).ToObservable(); + } + /// /// Returns the last year of commit activity grouped by week. /// @@ -48,6 +59,16 @@ namespace Octokit.Reactive return _client.Repository.Statistics.GetCommitActivity(owner, name).ToObservable(); } + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// The last year of + public IObservable GetCommitActivity(int repositoryId) + { + return _client.Repository.Statistics.GetCommitActivity(repositoryId).ToObservable(); + } + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -62,6 +83,16 @@ namespace Octokit.Reactive return _client.Repository.Statistics.GetCodeFrequency(owner, name).ToObservable(); } + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// Returns a weekly aggregate of the number additions and deletion + public IObservable GetCodeFrequency(int repositoryId) + { + return _client.Repository.Statistics.GetCodeFrequency(repositoryId).ToObservable(); + } + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -76,6 +107,16 @@ namespace Octokit.Reactive return _client.Repository.Statistics.GetParticipation(owner, name).ToObservable(); } + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// Returns from oldest week to now + public IObservable GetParticipation(int repositoryId) + { + return _client.Repository.Statistics.GetParticipation(repositoryId).ToObservable(); + } + /// /// Returns a list of the number of commits per hour in each day /// @@ -89,5 +130,15 @@ namespace Octokit.Reactive return _client.Repository.Statistics.GetPunchCard(owner, name).ToObservable(); } + + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// Returns commit counts per hour in each day + public IObservable GetPunchCard(int repositoryId) + { + return _client.Repository.Statistics.GetPunchCard(repositoryId).ToObservable(); + } } -} \ No newline at end of file +} diff --git a/Octokit/Clients/IStatisticsClient.cs b/Octokit/Clients/IStatisticsClient.cs index da06d2a5..41da8219 100644 --- a/Octokit/Clients/IStatisticsClient.cs +++ b/Octokit/Clients/IStatisticsClient.cs @@ -20,6 +20,13 @@ namespace Octokit /// A list of Task> GetContributors(string owner, string name); + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A list of + Task> GetContributors(int repositoryId); + /// /// Returns a list of for the given repository /// @@ -29,6 +36,14 @@ namespace Octokit /// A list of Task> GetContributors(string owner, string name, CancellationToken cancellationToken); + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// A list of + Task> GetContributors(int repositoryId, CancellationToken cancellationToken); + /// /// Returns the last year of commit activity grouped by week. /// @@ -37,6 +52,13 @@ namespace Octokit /// The last year of Task GetCommitActivity(string owner, string name); + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// The last year of + Task GetCommitActivity(int repositoryId); + /// /// Returns the last year of commit activity grouped by week. /// @@ -46,6 +68,14 @@ namespace Octokit /// The last year of Task GetCommitActivity(string owner, string name, CancellationToken cancellationToken); + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// The last year of + Task GetCommitActivity(int repositoryId, CancellationToken cancellationToken); + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -54,6 +84,13 @@ namespace Octokit /// Returns a weekly aggregate of the number additions and deletion Task GetCodeFrequency(string owner, string name); + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// Returns a weekly aggregate of the number additions and deletion + Task GetCodeFrequency(int repositoryId); + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -63,6 +100,14 @@ namespace Octokit /// Returns a weekly aggregate of the number additions and deletion Task GetCodeFrequency(string owner, string name, CancellationToken cancellationToken); + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns a weekly aggregate of the number additions and deletion + Task GetCodeFrequency(int repositoryId, CancellationToken cancellationToken); + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -71,6 +116,13 @@ namespace Octokit /// Returns from oldest week to now Task GetParticipation(string owner, string name); + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// Returns from oldest week to now + Task GetParticipation(int repositoryId); + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -80,6 +132,14 @@ namespace Octokit /// Returns from oldest week to now Task GetParticipation(string owner, string name, CancellationToken cancellationToken); + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns from oldest week to now + Task GetParticipation(int repositoryId, CancellationToken cancellationToken); + /// /// Returns a list of the number of commits per hour in each day /// @@ -88,6 +148,13 @@ namespace Octokit /// Returns commit counts per hour in each day Task GetPunchCard(string owner, string name); + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// Returns commit counts per hour in each day + Task GetPunchCard(int repositoryId); + /// /// Returns a list of the number of commits per hour in each day /// @@ -96,5 +163,13 @@ namespace Octokit /// A token used to cancel this potentially long running request /// Returns commit counts per hour in each day Task GetPunchCard(string owner, string name, CancellationToken cancellationToken); + + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns commit counts per hour in each day + Task GetPunchCard(int repositoryId, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/Octokit/Clients/StatisticsClient.cs b/Octokit/Clients/StatisticsClient.cs index 34aef9c8..03f69f78 100644 --- a/Octokit/Clients/StatisticsClient.cs +++ b/Octokit/Clients/StatisticsClient.cs @@ -29,9 +29,22 @@ namespace Octokit /// A list of public Task> GetContributors(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetContributors(owner, name, CancellationToken.None); } + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A list of + public Task> GetContributors(int repositoryId) + { + return GetContributors(repositoryId, CancellationToken.None); + } + /// /// Returns a list of for the given repository /// @@ -47,6 +60,17 @@ namespace Octokit return ApiConnection.GetQueuedOperation(ApiUrls.StatsContributors(owner, name), cancellationToken); } + /// + /// Returns a list of for the given repository + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// A list of + public Task> GetContributors(int repositoryId, CancellationToken cancellationToken) + { + return ApiConnection.GetQueuedOperation(ApiUrls.StatsContributors(repositoryId), cancellationToken); + } + /// /// Returns the last year of commit activity grouped by week. /// @@ -55,9 +79,22 @@ namespace Octokit /// The last year of public Task GetCommitActivity(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetCommitActivity(owner, name, CancellationToken.None); } + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// The last year of + public Task GetCommitActivity(int repositoryId) + { + return GetCommitActivity(repositoryId, CancellationToken.None); + } + /// /// Returns the last year of commit activity grouped by week. /// @@ -75,6 +112,19 @@ namespace Octokit return new CommitActivity(activity); } + /// + /// Returns the last year of commit activity grouped by week. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// The last year of + public async Task GetCommitActivity(int repositoryId, CancellationToken cancellationToken) + { + var activity = await ApiConnection.GetQueuedOperation( + ApiUrls.StatsCommitActivity(repositoryId), cancellationToken).ConfigureAwait(false); + return new CommitActivity(activity); + } + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -83,9 +133,22 @@ namespace Octokit /// Returns a weekly aggregate of the number additions and deletion public Task GetCodeFrequency(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetCodeFrequency(owner, name, CancellationToken.None); } + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// Returns a weekly aggregate of the number additions and deletion + public Task GetCodeFrequency(int repositoryId) + { + return GetCodeFrequency(repositoryId, CancellationToken.None); + } + /// /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. /// @@ -103,6 +166,19 @@ namespace Octokit return new CodeFrequency(rawFrequencies); } + /// + /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns a weekly aggregate of the number additions and deletion + public async Task GetCodeFrequency(int repositoryId, CancellationToken cancellationToken) + { + var rawFrequencies = await ApiConnection.GetQueuedOperation( + ApiUrls.StatsCodeFrequency(repositoryId), cancellationToken).ConfigureAwait(false); + return new CodeFrequency(rawFrequencies); + } + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -111,9 +187,22 @@ namespace Octokit /// Returns from oldest week to now public Task GetParticipation(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetParticipation(owner, name, CancellationToken.None); } + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// Returns from oldest week to now + public Task GetParticipation(int repositoryId) + { + return GetParticipation(repositoryId, CancellationToken.None); + } + /// /// Returns the total commit counts for the owner and total commit counts in total. /// @@ -131,6 +220,19 @@ namespace Octokit return result.FirstOrDefault(); } + /// + /// Returns the total commit counts for the owner and total commit counts in total. + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns from oldest week to now + public async Task GetParticipation(int repositoryId, CancellationToken cancellationToken) + { + var result = await ApiConnection.GetQueuedOperation( + ApiUrls.StatsParticipation(repositoryId), cancellationToken).ConfigureAwait(false); + return result.FirstOrDefault(); + } + /// /// Returns a list of the number of commits per hour in each day /// @@ -139,9 +241,22 @@ namespace Octokit /// Returns commit counts per hour in each day public Task GetPunchCard(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetPunchCard(owner, name, CancellationToken.None); } + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// Returns commit counts per hour in each day + public Task GetPunchCard(int repositoryId) + { + return GetPunchCard(repositoryId, CancellationToken.None); + } + /// /// Returns a list of the number of commits per hour in each day /// @@ -158,5 +273,18 @@ namespace Octokit ApiUrls.StatsPunchCard(owner, name), cancellationToken).ConfigureAwait(false); return new PunchCard(punchCardData); } + + /// + /// Returns a list of the number of commits per hour in each day + /// + /// The ID of the repository + /// A token used to cancel this potentially long running request + /// Returns commit counts per hour in each day + public async Task GetPunchCard(int repositoryId, CancellationToken cancellationToken) + { + var punchCardData = await ApiConnection.GetQueuedOperation( + ApiUrls.StatsPunchCard(repositoryId), cancellationToken).ConfigureAwait(false); + return new PunchCard(punchCardData); + } } } \ No newline at end of file