public async Task Execute(string token, string agenName, string owner, string repo, string branch) { using (var dbContext = new GitRepositoryDbContext(true)) { dbContext.Database.ExecuteSqlCommand($"TRUNCATE TABLE PullRequests"); var githubExtractor = new GithubDataFetcher(token, agenName, _logger); var pullRequests = await githubExtractor.FetchAllPullRequests(owner, repo).ConfigureAwait(false); _logger.LogInformation("{datetime}: trying to save {count} pull requests.", DateTime.Now, pullRequests.Length); foreach (PullRequest pullrequest in pullRequests) { var startdate = pullrequest.CreatedAtDateTime; var enddate = pullrequest.ClosedAtDateTime; var overlap = pullRequests.Where(a => a.ClosedAtDateTime > startdate && a.CreatedAtDateTime < enddate && a.Number != pullrequest.Number).ToList(); foreach (PullRequest item in overlap) { if (item.Number < pullrequest.Number) { pullrequest.OverlapPullRequest = string.Concat(pullrequest.OverlapPullRequest, item.Number.ToString() + ","); } } } dbContext.AddRange(pullRequests); dbContext.SaveChanges(); _logger.LogInformation("{datetime}: pull requests has been saved successfully.", DateTime.Now); } }
private LossSimulation CreateLossSimulation(LossSimulationOption lossSimulationOption) { var lossSimulation = new LossSimulation() { StartDateTime = DateTime.Now, MegaPullRequestSize = lossSimulationOption.MegaPullRequestSize, KnowledgeShareStrategyType = lossSimulationOption.KnowledgeShareStrategyType, LeaversType = lossSimulationOption.LeaversType, FilesAtRiksOwnershipThreshold = lossSimulationOption.FilesAtRiksOwnershipThreshold, FilesAtRiksOwnersThreshold = lossSimulationOption.FilesAtRiksOwnersThreshold, LeaversOfPeriodExtendedAbsence = lossSimulationOption.LeaversOfPeriodExtendedAbsence, KnowledgeSaveReviewerReplacementType = lossSimulationOption.KnowledgeSaveReviewerReplacementType, FirstPeriod = lossSimulationOption.KnowledgeSaveReviewerFirstPeriod, SelectedReviewersType = lossSimulationOption.SelectedReviewersType, PullRequestReviewerSelectionStrategy = lossSimulationOption.PullRequestReviewerSelectionStrategy, AddOnlyToUnsafePullrequests = lossSimulationOption.AddOnlyToUnsafePullrequests, MinimumActualReviewersLength = lossSimulationOption.MinimumActualReviewersLength, NumberOfPeriodsForCalculatingProbabilityOfStay = lossSimulationOption.NumberOfPeriodsForCalculatingProbabilityOfStay, LgtmTerms = lossSimulationOption.LgtmTerms.Aggregate((a, b) => a + "," + b), MegaDevelopers = lossSimulationOption.MegaDevelopers, RecommenderOption = lossSimulationOption.RecommenderOption, ChangePast = lossSimulationOption.ChangePast.Value }; _dbContext.Add(lossSimulation); _dbContext.SaveChanges(); return(lossSimulation); }
internal Task Execute(LossSimulationOption lossSimulationOption) { _dbContext = new GitRepositoryDbContext(false); var lossSimulation = CreateLossSimulation(lossSimulationOption); var timeMachine = CreateTimeMachine(lossSimulation); var knowledgeDistributioneMap = timeMachine.FlyInTime(); var leavers = GetLeavers(lossSimulation); using (var transaction = _dbContext.Database.BeginTransaction()) { SavePullRequestReviewes(knowledgeDistributioneMap, lossSimulation); _logger.LogInformation("{datetime}: RecommendedPullRequestReviewes are saved successfully.", DateTime.Now); SaveOwnershipDistribution(knowledgeDistributioneMap, lossSimulation, leavers); _logger.LogInformation("{datetime}: Ownership Distribution is saved Successfully.", DateTime.Now); SavePullRequestSimulatedRecommendationResults(knowledgeDistributioneMap, lossSimulation); _logger.LogInformation("{datetime}: Pull Requests Recommendation Results are saved Successfully.", DateTime.Now); SaveOpenReviews(knowledgeDistributioneMap, lossSimulation); _logger.LogInformation("{datetime}: Developer OpenReviews are saved successfully.", DateTime.Now); transaction.Commit(); _logger.LogInformation("{datetime}: Transaction is committed.", DateTime.Now); } _logger.LogInformation("{datetime}: trying to save results into database", DateTime.Now); _dbContext.SaveChanges(); lossSimulation.EndDateTime = DateTime.Now; _dbContext.Entry(lossSimulation).State = EntityState.Modified; _dbContext.SaveChanges(); _logger.LogInformation("{datetime}: results have been saved", DateTime.Now); _dbContext.Dispose(); return(Task.CompletedTask); }
public async Task Execute(string token, string agenName, string owner, string repo) { using (var dbContext = new GitRepositoryDbContext()) { var loadedIssues = dbContext.Issue.ToArray(); var githubExtractor = new GithubDataFetcher(token, agenName, _logger); var issueEvents = await githubExtractor.GetIssueEvents(owner, repo, loadedIssues).ConfigureAwait(false); dbContext.AddRange(issueEvents); dbContext.SaveChanges(); } }
public async Task Execute(string token, string agenName, string owner, string repo, string[] labels, string state = "All") { using (var dbContext = new GitRepositoryDbContext()) { dbContext.Database.ExecuteSqlCommand($"TRUNCATE TABLE Issue"); var githubExtractor = new GithubDataFetcher(token, agenName, _logger); var issues = await githubExtractor.GetIssues(owner, repo, labels, state).ConfigureAwait(false); dbContext.AddRange(issues); dbContext.SaveChanges(); } }
public async Task Execute(string token, string agenName, string owner, string repo, string branch) { using (var dbContext = new GitRepositoryDbContext(true)) { dbContext.Database.ExecuteSqlCommand($"TRUNCATE TABLE PullRequests"); var githubExtractor = new GithubDataFetcher(token, agenName, _logger); var pullRequests = await githubExtractor.FetchAllPullRequests(owner, repo).ConfigureAwait(false); _logger.LogInformation("{datetime}: trying to save {count} pull requests.", DateTime.Now, pullRequests.Length); dbContext.AddRange(pullRequests); dbContext.SaveChanges(); _logger.LogInformation("{datetime}: pull requests has been saved successfully.", DateTime.Now); } }