private static IEnumerable <IssueId> GetIssueIdsFromSource(string sourceName, IEnumerable <IssueId> source) { IssueId leastIssueId = null; IssueId maxIssueId = null; int issueIdCount = 0; foreach (var issueId in source) { if (leastIssueId == null || leastIssueId > issueId) { leastIssueId = issueId; } if (maxIssueId == null || maxIssueId < issueId) { maxIssueId = issueId; } issueIdCount++; yield return(issueId); } Logger.Debug($"issue ids from {sourceName}: {{cachedIds}}", new { min = leastIssueId, max = maxIssueId, count = issueIdCount }); }
public void IssuesByProject( ExportOptions exportOptions, [Option(Description = "Resumes export after this issue")] IssueId resumeAfter, [Option(Description = "Specify if the issue list should come from Jira, Cache or Both. " + "Use Jira when there are unknown updates or issues have been exported out of order by id. " + "Use Cache for speed when you only need to updates. " + "Using Both starts with Cache and then queries Jira for issue keys " + "greater than what have been cached per project.")] IssueSource?issueListSource = null, [Operand(Description = "The keys of the projects to export. If none are specified, all projects are exported")] List <string> projects = null) { if (_jiraApiSettings.JiraOffline && issueListSource.HasValue && issueListSource.Value.HasFlag(IssueSource.Jira)) { throw new ArgumentException( $"--{nameof(issueListSource)} cannot include {nameof(IssueSource.Jira)} " + $"when --{nameof(_jiraApiSettings.JiraOffline)} is specified."); } if (!_jiraApiSettings.JiraOffline) { ((CacheJiraApi)_jiraApi).IssueListSource = issueListSource.GetValueOrDefault(IssueSource.Both); } var projectFilter = new ProjectFilter { Projects = projects }; var issueIds = _jiraContext.Api.GetIssueIds(projectFilter, out int totalCount, resumeAfter); issueIds.EnumerateOperation(totalCount, "Export Issue", exportOptions.FailFile, _cancellationToken, ExportIssue); }
public IEnumerable <IssueId> GetIssueIdsByProject(string projectId, IssueId resumeAfterId = null, int?batchSize = null) { Logger.Debug("Begin JiraRestApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId, batchSize }); batchSize = batchSize ?? 100; var jql = BuildSearchJql(new[] { projectId }, resumeAfterId); var currentStart = 0; var pageCount = 0; List <IssueId> ids; do { var page = _jiraClient.Issues.GetIssuesFromJqlAsync(jql, startAt: currentStart, maxIssues: batchSize, token: _cancellationToken).Result; ids = page.Select(p => new IssueId(p.Key.Value)).ToList(); ids.Sort(); pageCount++; var totalPages = (page.TotalItems / batchSize) + 1; // plus 1 because it's unlikely the remainder is 0 Logger.Debug($"Fetched page {pageCount} of {totalPages}"); Logger.Trace("Returned ids: {ids}", ids); foreach (var id in ids) { yield return(id); } currentStart += batchSize.Value; } while (ids.Count >= batchSize && !_cancellationToken.IsCancellationRequested); }
public Task <int> GetTotalIssueCount(ICollection <string> projectIds, IssueId resumeAfterId = null) { var filteredProjects = _issuesByProject.Where(kvp => projectIds.Contains(kvp.Key)); int totalIssueCount = 0; if (resumeAfterId == null) { totalIssueCount = filteredProjects.Sum(kvp => kvp.Value.Count); } else { foreach (var project in filteredProjects) { var comparison = string.Compare(project.Key, resumeAfterId.Project, StringComparison.Ordinal); if (comparison == 0) { totalIssueCount += project.Value.Count(id => id > resumeAfterId); } else if (comparison > 0) { totalIssueCount += project.Value.Count; } } } return(Task.FromResult(totalIssueCount)); }
public IssueAssociatedWithNewBacklogItem(TenantId tenantId, ProductId productId, IssueId issueId) { TenantId = tenantId; ProductId = productId; IssueId = issueId; OccurredOn = DateTime.Now; }
public async Task <int> GetTotalIssueCount(ICollection <string> projectIds, IssueId resumeAfterId = null) { var jql = BuildSearchJql(projectIds, resumeAfterId); var page = await _jiraClient.Issues.GetIssuesFromJqlAsync(jql, startAt : 0, maxIssues : 1, token : _cancellationToken); return(page.TotalItems); }
public IssueMigration Get(IssueId issueId) { var migration = _migrationRepository.GetOrCreate(issueId); UpdateMigrationMetaData(migration); return(migration); }
void MustBeActive(TenantId tenant = null, ProductId product = null, IssueId ticket = null,IssueAssignerId assigner=null) { if (tenant != null) Guard.That(Queries.IsActive(tenant), "This is an inactive tenant"); if (product != null) Guard.That(Queries.IsActive(tenant,product), "This is an inactive product"); if (ticket != null) Guard.That(Queries.IsActive(tenant, product, ticket), "This is an inactive ticket"); if (assigner != null) Guard.That(Queries.IsActive(tenant, assigner), "This is an inactive assigner"); }
public WorkItem GetWorkItem(IssueId jiraId) { Logger.Debug("Get work item by jira id {jiraId}", jiraId); var wiql = $@"select * from workitems where {_adoApiSettings.JiraIdField} = '{jiraId}'"; return(_workItemStore.Query(wiql).OfType <WorkItem>().FirstOrDefault()); }
public void SaveIssue(IssueId issueId, JObject issue) { var file = _localDirs.GetIssueJsonFile(issueId); Logger.Trace("Save issue to file: {file}", file.FullName); File.WriteAllText(file.FullName, issue.ToString()); }
public Task <JObject> GetIssue(IssueId issueId) { var file = _localDirs.GetIssueJsonFile(issueId); Logger.Trace("Get issue from file: {file}", file.FullName); return(LoadJsonFromFile <JObject>(file)); }
public Issue GetById(IssueId id) { var dto = _issueRepository.GetAll() .First(x => x.Id == id); return(ConvertFromDto(dto)); }
public IEnumerable <IssueId> GetIssueIdsByProject(string projectId, IssueId resumeAfterId = null) { Logger.Debug("Begin JiraCacheApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId }); if (IssueListSource.HasFlag(IssueSource.Cache)) { foreach (var issueId in GetIssueIdsFromSource("cache-by-project", _cacheApi.GetIssueIdsByProject(projectId, resumeAfterId))) { if (resumeAfterId == null || resumeAfterId < issueId) { resumeAfterId = issueId; } yield return(issueId); } } if (IssueListSource.HasFlag(IssueSource.Jira)) { foreach (var issueId in GetIssueIdsFromSource("jira-by-project", _sourceApi.GetIssueIdsByProject(projectId, resumeAfterId))) { yield return(issueId); } } }
public void WithNull_False() { IssueId vo = Freeze.GuidOne; var actually = vo.Equals(null); actually.Should().BeFalse(); }
public void ObjectWithUnderlyingDifferentValue_True() { IssueId vo = Freeze.GuidOne; var actually = vo != Freeze.GuidTwo; actually.Should().BeTrue(); }
private CompileIssue(IssueLocation location, IssueType type, IssueId id) { this._id = id; this._issueType = type; _desc = id.GetDescription(); _msg = _desc; _location = location; }
public void UnderlyingWithObjectDifferentValue_False() { IssueId vo = Freeze.GuidOne; var actually = Freeze.GuidTwo == vo; actually.Should().BeFalse(); }
public async Task <JObject> GetIssue(IssueId issueId) { // TODO: check the page properties for comments and changelogs. Fetch and merge remaining pages when available. Logger.Debug("Fetching issue {issueId}", issueId); var url = $"{_apiUrl}/issue/{issueId}?fields=*all&expand=changelog,renderedFields"; return((JObject)await _restClient.ExecuteRequestAsync(Method.GET, url, token : _cancellationToken).ConfigureAwait(false)); }
public void ObjectWithUnderlyingSameValue_False() { IssueId vo = Freeze.GuidOne; var actually = vo != Freeze.GuidOne; actually.Should().BeFalse(); }
public void UnderlyingWithObjectSameValue_False() { IssueId vo = Freeze.GuidOne; var actually = Freeze.GuidOne != vo; actually.Should().BeFalse(); }
public async Task <JObject> GetIssue(IssueId issueId) { return(await CallAndCache( "issue", issueId.ToString(), api => api.GetIssue(issueId), onSetCache : result => _cacheApi.SaveIssue(issueId, result))); }
public void ToStringTestCases() { IssueId vo = Freeze.GuidFortyTwo; var actually = vo.ToString(); actually.Should().Be(Freeze.GuidFortyTwo.ToString()); }
public void OneObject_UniqueHash() { IssueId vo = Freeze.GuidOne; var hash = vo.GetHashCode(); hash.Should().Be(-92871782); }
public IEnumerable <IssueId> GetIssueIdsByProject(string projectId, IssueId resumeAfterId = null) { Logger.Debug("Begin LocalDirJiraApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId }); return(_issuesByProject.GetOrAdd(projectId, new HashSet <IssueId>()) .OrderBy(id => id) .SkipWhile(id => resumeAfterId != null && id <= resumeAfterId)); }
public void DifferentObjectsSameValue_False() { IssueId vo1 = Freeze.GuidOne; IssueId vo2 = Freeze.GuidOne; var actually = vo1 != vo2; actually.Should().BeFalse(); }
public void DifferentObjectsAndValues_True() { IssueId vo1 = Freeze.GuidOne; IssueId vo2 = Freeze.GuidTwo; var actually = vo1 != vo2; actually.Should().BeTrue(); }
public void EmptyGuid_ArgumentException() { this.Invoking(_ => { IssueId __ = Freeze.GuidEmpty.ToString(); }) .Should().ThrowExactly <ArgumentException>() .WithMessage("The IssueId must be a valid guid."); }
public void WithSomethingDifferent_False() { IssueId vo = Freeze.GuidOne; // ReSharper disable once SuspiciousTypeConversion.Global var actually = vo.Equals(DateTime.UtcNow); actually.Should().BeFalse(); }
public void WithEmptyObject_False() { IssueId vo = Freeze.GuidOne; var empty = new IssueId(); var actually = vo.Equals(empty); actually.Should().BeFalse(); }
public void WithSameObject_True() { IssueId vo = Freeze.GuidOne; var one = new IssueId(Freeze.GuidOne); var actually = vo.Equals(one); actually.Should().BeTrue(); }
public void ValidGuid_WithValue() { IssueId vo = Freeze.GuidFortyTwo.ToString(); using (new AssertionScope()) { vo.HasValue.Should().BeTrue(); vo.Value.Should().Be(Freeze.GuidFortyTwo); } }
public IssueMigration Get(IssueId issueId) { var file = _localDirs.GetIssueMigrationStatusFile(issueId); if (!file.Exists) { return(null); } return(LoadFromFile(file)); }
private void AppendCompileIssue(SyntaxToken token, IssueType type, IssueId id, params object[] args) { var issue = CompileIssue.Create(this._semanticModel.SyntaxTree, token, type, id, args); _aggregator.AppendIssue(issue); }
public void CloseIssue(TenantId Tenant, ProductId Product, IssueId Id) { MustBeActive(Tenant, Product, Id); Changes.IssueClosed(Tenant, Product, Id); }
public void ReportDefect(TenantId Tenant, ProductId Product, IssueId Id, string Name, string Description,IssueAssignerId Assigner) { MustBeActive(Tenant, Product); Changes.IssueRegistered(Tenant, Product, Id, Name, Description,IssueType.Defect,Assigner); }
public void RequestFeature(TenantId Tenant, ProductId Product, IssueId Id, string Name, string Description,IssueAssignerId Assigner) { MustBeActive(Tenant,Product); MustBeActive(Tenant,assigner:Assigner); Changes.IssueRegistered(Tenant,Product,Id, Name, Description,IssueType.Feature,Assigner); }
private CompileIssue(IssueLocation location, IssueType type, IssueId id, params object[] args) : this(location, type, id) { _msg = _desc.TryFormat(args); }
public static CompileIssue CreateNoLocationIssue(IssueType type, IssueId id, params object[] args) { CompileIssue issue = new CompileIssue(IssueLocation.NA, type, id, args); return issue; }
public static CompileIssue Create(SyntaxTree tree, SyntaxToken token, IssueType type, IssueId id, params object[] args) { IssueLocation loc = new IssueLocation(tree, token); CompileIssue issue = new CompileIssue(loc, type, id, args); return issue; }