public void RequestsCorrectUrlWithApiOptions() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var request = new IssueCommentRequest() { Direction = SortDirection.Descending, Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), Sort = IssueCommentSort.Updated }; var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; client.GetAllForRepository("fake", "repo", request, options); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Arg.Is <Dictionary <string, string> >(d => d.Count == 5 && d["direction"] == "desc" && d["since"] == "2016-11-23T11:11:11Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview"); }
public async Task <IEnumerable <Data.IssueComment> > FetchPullRequestIssueCommentsFromRepository(string owner, string repo, Data.PullRequest[] pullRequests) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); _logger.LogInformation("{datetime}: fetching all the issue comments from {owner}/{repo}.", DateTime.Now, owner, repo); var requestFilter = new IssueCommentRequest() { Sort = IssueCommentSort.Updated, Direction = SortDirection.Ascending }; var allComments = new List <Data.IssueComment>(); foreach (var pullRequest in pullRequests) { var issueComments = await _client.Issue.Comment.GetAllForIssue(owner, repo, pullRequest.Number, new ApiOptions() { PageSize = 1000 }).ConfigureAwait(false); allComments.AddRange(Mapper.Map <Data.IssueComment[]>(issueComments.ToArray())); } _logger.LogInformation("{datetime}: {count} issue comments have been fetched.", DateTime.Now, allComments.Count); return(allComments); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> public IObservable <IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options)); }
private static async Task GetComments(GitHubClient client, StringBuilder content, DateTime fromDate, DateTime toDate, bool isSortByCreated, HashSet <int> commentsAdded) { IssueCommentsClient issueCommentsClient = new IssueCommentsClient(new ApiConnection(client.Connection)); IssueCommentRequest commentRequest = new IssueCommentRequest() { Since = fromDate, Direction = SortDirection.Ascending, Sort = isSortByCreated ? IssueCommentSort.Created : IssueCommentSort.Updated }; ApiOptions commentOptions = new ApiOptions() { PageSize = MaxPerPage, PageCount = 1, StartPage = 1 }; bool hasMoreComments = true; while (hasMoreComments) { var comments = await issueCommentsClient.GetAllForRepository(RepoOwner, RepoName, commentRequest, commentOptions); foreach (var comment in comments) { bool isInDateRange = isSortByCreated ? (comment.CreatedAt >= fromDate && comment.CreatedAt <= toDate) : (comment.UpdatedAt >= fromDate && comment.UpdatedAt <= toDate); if (isInDateRange) { if (!commentsAdded.Contains(comment.Id)) { commentsAdded.Add(comment.Id); bool isInternal = KnownInternalContributors.Contains(comment.User.Login); string issueType = "Comment"; string relation = StoreAndGetIssueRelation(isInternal, issueType); content.AppendLine(comment.User.Login + "\t" + comment.HtmlUrl + "\t" + "NA" + "\t" + comment.AuthorAssociation + "\t" + issueType + "\t" + relation + "\t" + comment.CreatedAt + "\t" + comment.UpdatedAt); contributors.Add(comment.User.Login); } } else { // Outside date range hasMoreComments = false; break; // from inner loop } } if (hasMoreComments && comments.Count == MaxPerPage) { commentOptions.StartPage++; } else { hasMoreComments = false; } } }
public async Task <List <IssueComment> > CommentsSince(long repo, DateTimeOffset start) { List <IssueComment> issues = new List <IssueComment>(); var shouldPrioritize = new IssueCommentRequest { Sort = IssueCommentSort.Created, Since = start }; var results = await client.Issue.Comment.GetAllForRepository(repo, shouldPrioritize); return(results.ToList()); }
public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); var request = new IssueCommentRequest() { Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), }; await client.GetAllForIssue(1, 3, request); connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); }
public void RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var request = new IssueCommentRequest() { Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), }; client.GetAllForIssue(1, 3, request); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Is <Dictionary <string, string> >(d => d.Count == 3 && d["since"] == "2016-11-23T11:11:11Z"), "application/vnd.github.squirrel-girl-preview"); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> public IObservable <IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options)); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> public IObservable <IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return(GetAllForRepository(repositoryId, request, ApiOptions.None)); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> public IObservable <IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); return(GetAllForRepository(owner, name, request, ApiOptions.None)); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> public IObservable<IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> public IObservable<IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> public IObservable<IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request) { Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(repositoryId, request, ApiOptions.None); }
/// <summary> /// Gets Issue Comments for a repository. /// </summary> /// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> public IObservable<IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(owner, name, request, ApiOptions.None); }
public void RequestsCorrectUrlWithApiOptions() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var request = new IssueCommentRequest() { Direction = SortDirection.Descending, Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), Sort = PullRequestReviewCommentSort.Updated }; var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; client.GetAllForRepository("fake", "repo", request, options); gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["direction"] == "desc" && d["since"] == "2016-11-23T11:11:11Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview"); }