public void UpdateAllIssues(PerformContext context) { var repoManagementService = new RepositoryManagementService(); var repositories = repoManagementService.GetAllPublicRepositories(); var gitHubService = new GitHubService(); foreach (var repository in repositories) { //RecurringJob.AddOrUpdate($"[IssueTracker] FullUpdate {repository.Name}", () => gitHubService.UpdateReviews(context, repository), Cron.Yearly(2, 31)); } }
public void UpdateGitHubIssues(PerformContext context) { var repoManagementService = new RepositoryManagementService(); var repositories = repoManagementService.GetAllPublicRepositories(); var gitHubService = new GitHubService(); foreach (var repository in repositories) { RecurringJob.AddOrUpdate($"[IssueTracker] Update {repository.Name}", () => gitHubService.UpdateIssues(context, repository), Cron.MinuteInterval(5)); } }
public List <string> GetPullRequestStats(string startDate, string endDate) { if (DateTime.TryParse(startDate, out var start) == false) { return(null); } if (DateTime.TryParse(endDate, out var end) == false) { return(null); } var repoManagementService = new RepositoryManagementService(); var repositories = repoManagementService.GetAllPublicRepositories().Where(x => x.InDashboard); var githubService = new GitHubService(); var contributors = new HashSet <string>(); foreach (var repository in repositories) { var allPulls = githubService .GetExistingPullsFromDisk(repository.Alias) .Where(x => x != null && x.IsPr && x.CreateDateTime >= start && x.CreateDateTime < end); foreach (var pull in allPulls) { contributors.Add(pull.User.Login); } } var hqUsersFile = HostingEnvironment.MapPath("~/Config/githubhq.txt"); var hqList = System.IO.File.ReadAllLines(hqUsersFile).Where(x => x.Trim() != "").Distinct().ToArray(); var contribFiltered = new List <string>(); foreach (var contributor in contributors) { if (hqList.Any(x => string.Equals(x, contributor, StringComparison.InvariantCultureIgnoreCase)) == false) { contribFiltered.Add(contributor); } } return(contribFiltered); }
public IssueStatistics GetIssueStatistics(int startMonth = 6, int startYear = 2010, string repository = "", bool monthly = true) { var repoService = new RepositoryManagementService(); var repositories = repoService.GetAllPublicRepositories().Where(x => x.InDashboard); var stats = new IssueStatistics { NoCommentIssues = new List <Issue>(), Repositories = new HashSet <string>(), Stats = new List <Statistics>() }; var allCommunityIssues = string.IsNullOrWhiteSpace(repository) ? repoService.GetAllCommunityIssues(false).Where(x => repositories.Any(r => r.Alias == x.RepositoryName)).ToList() : repoService.GetAllCommunityIssues(false).Where(x => x.RepositoryName == repository).ToList(); var date = new DateTime(startYear, startMonth, 1); while (date < DateTime.Now) { var year = date.Year; var endMonth = monthly ? date.AddMonths(1).Month : date.AddYears(1).Month; var endYear = monthly ? date.AddMonths(1).Year : date.AddYears(1).Year; var startDate = new DateTime(year, date.Month, 1); var endDate = new DateTime(endYear, endMonth, 1); var issuesInPeriod = allCommunityIssues.Where(x => x.CreateDateTime >= startDate && x.CreateDateTime < endDate).ToList(); var issuesClosedInPeriod = issuesInPeriod.Where(x => x.State == "closed" && x.ClosedDateTime >= startDate && x.ClosedDateTime < endDate).ToList(); var yearStatistics = new Statistics { CodegardenYear = year, Title = date.ToString(monthly ? "yyyyMM" : "yyyy"), CreatedIssues = issuesInPeriod.Count, ClosedIssues = issuesClosedInPeriod.Count, FirstCommentStatistics = new FirstCommentStatistics { AllFirstEventTimesInHours = new List <double>() }, AllIssues = issuesInPeriod }; var allFirstCommentTimesInHours = new List <double>(); var allClosingTimesInHours = new List <double>(); foreach (var issue in issuesInPeriod) { stats.Repositories.Add(issue.RepositoryName); var firstCommentStatistics = GetFirstEventStatistics(issue); foreach (var noCommentIssue in firstCommentStatistics.IssuesNoComments) { if (stats.NoCommentIssues.Contains(noCommentIssue) == false) { stats.NoCommentIssues.Add(noCommentIssue); } } yearStatistics.FirstCommentStatistics.FirstEventOnTime += firstCommentStatistics.FirstEventOnTime; yearStatistics.FirstCommentStatistics.FirstEventLate += firstCommentStatistics.FirstEventLate; yearStatistics.FirstCommentStatistics.TeamEventMissing += firstCommentStatistics.TeamEventMissing; allFirstCommentTimesInHours.AddRange(firstCommentStatistics.AllFirstEventTimesInHours); if (issue.ClosedDateTime != null) { var timeSpan = Convert.ToInt32(issue.CreateDateTime.BusinessHoursUntil(issue.ClosedDateTime.Value)); allClosingTimesInHours.Add(timeSpan); if (issue.Labels.Any(x => x.Name.StartsWith("release/"))) { yearStatistics.ReleaseIssues += 1; } } } if (allFirstCommentTimesInHours.Any()) { yearStatistics.AverageHoursToFirstComment = (int)Math.Round(allFirstCommentTimesInHours.Average()); yearStatistics.MedianHoursToFirstComment = (int)Math.Round(allFirstCommentTimesInHours.Median()); } if (allClosingTimesInHours.Any()) { yearStatistics.AverageHoursToClose = (int)Math.Round(allClosingTimesInHours.Average()); yearStatistics.MedianHoursToClose = (int)Math.Round(allClosingTimesInHours.Median()); } stats.Stats.Add(yearStatistics); date = monthly ? date.AddMonths(1) : date.AddYears(1); } return(stats); }