/// <summary> /// Populates the milestone tableo to be equivalent to the current set of milestones on GitHub. /// </summary> public async Task PopulateMilestones(RoachRepoId repoId, CancellationToken cancellationtoken = default(CancellationToken)) { var milestones = await _storageQueryUtil.GetMilestones(repoId, RoachItemFilter.All, cancellationtoken); var map = milestones.ToDictionary(x => x.Number); var list = new List <RoachMilestoneEntity>(); foreach (var milestone in await _githubQueryUtil.GetMilestones(repoId)) { var isOpen = milestone.State == ItemState.Open; RoachMilestone r; if (!map.TryGetValue(milestone.Number, out r) || r.Title != milestone.Title || r.IsOpen != isOpen) { r = new RoachMilestone(repoId, milestone.Number, milestone.Title, isOpen); list.Add(new RoachMilestoneEntity(r)); } } if (list.Count > 0) { // TODO: Need to thread through the CancellationToken here. await AzureUtil.InsertBatchUnordered(_milestoneTable, list); } }
/// <summary> /// Populates the issues tables to reflect changes that occured since the see cref="since"/> parameter. /// </summary> public async Task PopulateIssuesSince(RoachRepoId repoId, DateTimeOffset since, CancellationToken cancellationtoken = default(CancellationToken)) { var changedIssues = await _githubQueryUtil.GetIssuesChangedSince(repoId, since); var issueList = new List <RoachIssueEntity>(capacity: changedIssues.Count); foreach (var changedIssue in changedIssues) { var issue = new RoachIssue(repoId, changedIssue); issueList.Add(new RoachIssueEntity(issue)); } // TODO: Need to thread through the CancellationToken here. await AzureUtil.InsertBatchUnordered(_issueTable, issueList); }
private async Task PopulateIssues(TextWriter logger) { var util = new GitHubQueryUtil(_client); var request = new RepositoryIssueRequest() { State = ItemStateFilter.All }; logger.WriteLine($"Getting issues"); var issues = await util.GetIssues(_repoId, request); var list = new List <RoachIssueEntity>(); foreach (var issue in issues) { var entity = new RoachIssueEntity(new RoachIssue(_repoId, issue)); list.Add(entity); } logger.WriteLine("Populating issues table storage"); await AzureUtil.InsertBatchUnordered(_issueTable, list); }