private static async Task <DateTimeOffset?> GetWorkingStartTime(RepoDefinition repo, Issue issue, string[] workingLabels, GitHubClient gitHubClient) { var workingLabelsOnThisIssue = issue.Labels .Where(label => workingLabels.Contains(label.Name, StringComparer.OrdinalIgnoreCase)) .Select(label => label.Name); if (!workingLabelsOnThisIssue.Any()) { // Item isn't in any Working state, so ignore it return(null); } // Find all "labeled" events for this issue var issueEvents = await gitHubClient.Issue.Events.GetAllForIssue(repo.Owner, repo.Name, issue.Number); foreach (var workingLabelOnThisIssue in workingLabelsOnThisIssue) { var labelEvent = issueEvents.LastOrDefault( issueEvent => issueEvent.Event == EventInfoState.Labeled && string.Equals(issueEvent.Label.Name, workingLabelOnThisIssue, StringComparison.OrdinalIgnoreCase)); if (labelEvent != null) { // If an event where this label was applied was found, return the date on which it was applied return(labelEvent.CreatedAt); } } return(null); }
private RepoTask <IReadOnlyList <PullRequest> > GetPullRequestsForRepo(RepoDefinition repo, GitHubClient gitHubClient) { return(new RepoTask <IReadOnlyList <PullRequest> > { Repo = repo, Task = gitHubClient.PullRequest.GetAllForRepository(repo.Owner, repo.Name), }); }
private bool ItemIncludedByInclusionLevel(string itemAssignee, RepoDefinition repo, string[] peopleInPersonSet) { if (repo.RepoInclusionLevel == RepoInclusionLevel.AllItems) { return(true); } if (repo.RepoInclusionLevel == RepoInclusionLevel.ItemsAssignedToPersonSet) { return(peopleInPersonSet.Contains(itemAssignee, StringComparer.OrdinalIgnoreCase)); } return(false); }
private RepoTask <IReadOnlyList <Issue> > GetIssuesForRepo(RepoDefinition repo, GitHubClient gitHubClient) { var repositoryIssueRequest = new RepositoryIssueRequest { State = ItemState.Open, }; return(new RepoTask <IReadOnlyList <Issue> > { Repo = repo, Task = gitHubClient.Issue.GetAllForRepository(repo.Owner, repo.Name, repositoryIssueRequest), }); }
private RepoTask <IReadOnlyList <PullRequest> > GetPullRequestsForRepo(RepoDefinition repo, IGitHubClient gitHubClient, string metricsPrefix) { async Task <IReadOnlyList <PullRequest> > RunRequestAsync() { using (_metricsService.Time($"{metricsPrefix}:Repo({repo.Owner}/{repo.Name}):GetAllPullRequests")) { return(await gitHubClient.PullRequest.GetAllForRepository(repo.Owner, repo.Name)); } } return(new RepoTask <IReadOnlyList <PullRequest> > { Repo = repo, Task = RunRequestAsync(), }); }
private RepoTask <IReadOnlyList <Issue> > GetIssuesForRepo(RepoDefinition repo, IGitHubClient gitHubClient, string metricsPrefix) { async Task <IReadOnlyList <Issue> > RunRequestAsync() { var repositoryIssueRequest = new RepositoryIssueRequest { State = ItemStateFilter.Open, }; using (_metricsService.Time($"{metricsPrefix}:Repo({repo.Owner}/{repo.Name}):GetAllIssues")) { return(await gitHubClient.Issue.GetAllForRepository(repo.Owner, repo.Name, repositoryIssueRequest)); } } return(new RepoTask <IReadOnlyList <Issue> > { Repo = repo, Task = RunRequestAsync(), }); }