Beispiel #1
0
        public async Task <List <RoachMilestone> > GetMilestones(RoachRepoId repoId, RoachItemFilter filter = RoachItemFilter.All, CancellationToken cancellationToken = default(CancellationToken))
        {
            var util = FilterUtil.PartitionKey(RoachMilestoneEntity.GetPartitionKey(repoId));

            switch (filter)
            {
            case RoachItemFilter.All:
                // Nothing to do:
                break;

            case RoachItemFilter.Closed:
                util = util.And(FilterUtil.Column(nameof(RoachMilestoneEntity.IsOpen), false));
                break;

            case RoachItemFilter.Open:
                util = util.And(FilterUtil.Column(nameof(RoachMilestoneEntity.IsOpen), true));
                break;

            default:
                throw new Exception($"Bad enum value {filter}");
            }


            var list = await AzureUtil.QueryAsync <RoachMilestoneEntity>(
                _milestoneTable,
                util,
                cancellationToken);

            return(list.Select(x => x.Milestone).OrderBy(x => x.Title).ToList());
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get all issues in the specified label which don't have an assignee and / or a milestone.
        /// </summary>
        public async Task <List <RoachIssue> > GetTriageIssues(RoachRepoId repoId, string label, CancellationToken cancellationToken)
        {
            var unassignedFilter = TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition(nameof(TableEntity.PartitionKey), QueryComparisons.Equal, EntityKeyUtil.ToKey(repoId)),
                TableOperators.And,
                TableQuery.GenerateFilterCondition(nameof(RoachIssueEntity.Assignee), QueryComparisons.Equal, TheBugsConstants.UnassignedName));
            var unassignedList = await AzureUtil.QueryAsync(_issueTable, new TableQuery <RoachIssueEntity>().Where(unassignedFilter), cancellationToken);

            var unknownMilestoneFilter = TableQuery.CombineFilters(
                TableQuery.GenerateFilterCondition(nameof(TableEntity.PartitionKey), QueryComparisons.Equal, EntityKeyUtil.ToKey(repoId)),
                TableOperators.And,
                TableQuery.GenerateFilterConditionForInt(nameof(RoachIssueEntity.MilestoneNumber), QueryComparisons.Equal, RoachMilestoneId.NoneNumber));
            var unknownMilestoneList = await AzureUtil.QueryAsync(_issueTable, new TableQuery <RoachIssueEntity>().Where(unknownMilestoneFilter), cancellationToken);

            var list    = new List <RoachIssue>();
            var hashSet = new HashSet <int>();

            foreach (var entity in unassignedList.Concat(unknownMilestoneList))
            {
                if (hashSet.Add(entity.Number) && entity.Labels.Contains(label) && entity.IssueType == IssueType.Issue)
                {
                    list.Add(entity.Issue);
                }
            }

            return(list);
        }
Beispiel #4
0
 public EntityKey(string partitionKey, string rowKey)
 {
     Debug.Assert(!AzureUtil.IsIllegalKey(partitionKey));
     Debug.Assert(!AzureUtil.IsIllegalKey(rowKey));
     PartitionKey = partitionKey;
     RowKey       = rowKey;
 }
Beispiel #5
0
        private async Task <List <RoachIssueEntity> > GetIssuesInMilestone(RoachRepoId repoId, int milestone, CancellationToken cancellationToken)
        {
            var filter = FilterUtil
                         .PartitionKey(RoachIssueEntity.GetPartitionKey(repoId))
                         .And(FilterUtil.Column(nameof(RoachIssueEntity.MilestoneNumber), milestone));

            return(await AzureUtil.QueryAsync <RoachIssueEntity>(_issueTable, filter, cancellationToken));
        }
Beispiel #6
0
        /// <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);
        }
Beispiel #7
0
        private async Task <List <RoachIssueEntity> > GetIssuesInMilestones(RoachRepoId repoId, List <int> milestones, CancellationToken cancellationToken)
        {
            if (milestones == null || milestones.Count == 0)
            {
                // Return all of the issues
                return(await AzureUtil.QueryAsync <RoachIssueEntity>(_issueTable, FilterUtil.PartitionKey(RoachIssueEntity.GetPartitionKey(repoId)), cancellationToken));
            }

            var list = new List <RoachIssueEntity>();

            foreach (var milestone in milestones)
            {
                list.AddRange(await GetIssuesInMilestone(repoId, milestone, cancellationToken));
            }

            return(list);
        }
Beispiel #8
0
        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);
        }