private Task <IEnumerable <MergeRequest> > loadMergeRequests(GitLab gl, MergeRequestsFilter filter) { if (_query.MaxResults.HasValue && !String.IsNullOrWhiteSpace(_query.ProjectName)) { return(gl .Projects .Get(_query.ProjectName) .MergeRequests .LoadTaskAsync(filter, getTrivialPageFilter())); } else if (_query.MaxResults.HasValue) { return(gl .MergeRequests .LoadTaskAsync(filter, getTrivialPageFilter())); } else if (!String.IsNullOrWhiteSpace(_query.ProjectName)) { return(gl .Projects .Get(_query.ProjectName) .MergeRequests .LoadAllTaskAsync(filter)); } else { return(gl .MergeRequests .LoadAllTaskAsync(filter)); } }
async protected Task <IEnumerable <MergeRequest> > load(GitLab gl, string projectname, int?maxResults, MergeRequestsFilter filter) { Task <IEnumerable <MergeRequest> > t = maxResults.HasValue ? gl.Projects.Get(projectname).MergeRequests.LoadTaskAsync(filter, new PageFilter(maxResults.Value, 1)) : gl.Projects.Get(projectname).MergeRequests.LoadAllTaskAsync(filter); return(await t); }
async internal Task <IEnumerable <MergeRequest> > Process(GitLab gl) { // See restrictions at https://docs.gitlab.com/ee/api/README.html#offset-based-pagination Debug.Assert(!_query.MaxResults.HasValue || _query.MaxResults.Value <= 100); int?authorId = await getAuthorId(gl); int? iid = getIId(); string labels = getLabels(); string stateFilter = getStateFilter(); MergeRequestsFilter.WorkInProgressFilter wipStatus = getWIPFilter(); MergeRequestsFilter filter = new MergeRequestsFilter(labels, wipStatus, stateFilter, false, _query.Text, _query.TargetBranchName, iid.HasValue ? new int[] { iid.Value } : null, authorId); IEnumerable <MergeRequest> mergeRequests = await loadMergeRequests(gl, filter); return(filterMergeRequests(iid, mergeRequests, stateFilter)); }