Esempio n. 1
0
        /// <summary>
        /// Handles paginating and other subsequent requests for a single repo.
        /// </summary>
        /// <returns>The responses.</returns>
        /// <param name="repoNode">Repo node.</param>
        /// <param name="prList">Pr list.</param>
        private void SubsequentResponses(gh.RepoNode repoNode, List <PullRequest> prList)
        {
            // This means we're paginating, so check where we are at - always the same in this function
            int newTotal = repoNode.pullRequests.edges.Count + _repoList[_currentKey];

            if (newTotal >= repoNode.pullRequests.totalCount)
            {
                _repoList.Remove(_currentKey);
                // Nothing left to paginate
                if (_repoList.Count < 1)
                {
                    _currentKey = string.Empty;
                    _nextCursor = string.Empty;
                }
                // Look through remaining keys, grab the first and add in the apropriate cursor for pagination
                else
                {
                    foreach (string repoName in _repoList.Keys)
                    {
                        _currentKey = repoName;
                        _nextCursor = _startingCursorList[repoName];
                        break;
                    }
                }
            }
            // Not done paginating, just grab the next cursor and add in the update
            else
            {
                _repoList[_currentKey] = newTotal;
                _nextCursor            = repoNode.pullRequests.pageInfo.endCursor;
            }

            // Still add them (but only the one we're paginating - not the others since those are repeats
            ConvertGithubPullRequests(prList, repoNode.pullRequests);
        }
Esempio n. 2
0
        /// <summary>
        /// Parses the GraphQL response for just pull requests
        /// </summary>
        /// <returns>The repo graph QLR esponse.</returns>
        /// <param name="ghPulls">Gh pulls.</param>
        private List <PullRequest> ParseRepoGraphQLResponse(gh.GraphQLRepoSpecificPullRequest resultNode)
        {
            List <PullRequest> prList = new List <PullRequest>();

            // First loop through repos to setup pagination
            //  Track each repo name and then track the current count of entries within the dictionary
            //  Compare this to the total count

            // This is the first instance if dictionary is null - but we know we only have one
            gh.RepoNode repoNode = resultNode.data.repository;
            if (_repoList == null)
            {
                _repoList = new Dictionary <string, int>();
                FirstResponse(repoNode, prList);
                _currentKey = repoNode.name;
                _nextCursor = repoNode.pullRequests.pageInfo.endCursor;
                return(prList);
            }

            // Quick check in-case
            if (_repoList.Count < 1)
            {
                return(prList);
            }

            SubsequentResponses(repoNode, prList);

            return(prList);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the first pass for a single repo..
        /// </summary>
        /// <returns>The response.</returns>
        /// <param name="repoNode">Repo node.</param>
        /// <param name="prList">Pr list.</param>
        private void FirstResponse(gh.RepoNode repoNode, List <PullRequest> prList)
        {
            // Now check if what was returned wasn't equal to the total (meaning we didn't get it all in one grab and add it)
            if (repoNode.pullRequests.edges.Count != repoNode.pullRequests.totalCount)
            {
                _repoList.Add(repoNode.name, repoNode.pullRequests.edges.Count);
                _startingCursorList.Add(repoNode.name, repoNode.pullRequests.pageInfo.endCursor);
            }

            // Still add them
            ConvertGithubPullRequests(prList, repoNode.pullRequests);
        }