コード例 #1
0
        private Nullable <DateTime> ComputeFinished()
        {
            // not yet finished
            if (this._issue.CurrentStatus == null || this._issue.CurrentStatus.Category != JiraStatusCategory.Done)
            {
                return(null);
            }

            JiraIssueChange doneChange = null;

            for (var i = this._issue.Changes.Count - 1; i >= 0; i--)
            {
                if (doneChange == null)
                {
                    if (this._issue.Changes[i].RealCategory == JiraStatusCategory.Done)
                    {
                        doneChange = this._issue.Changes[i];
                    }
                }
                else
                {
                    if (this._issue.Changes[i].RealCategory == JiraStatusCategory.Done)
                    {
                        doneChange = this._issue.Changes[i];
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (doneChange == null)
            {
                return(this._issue.ResolutionDate);
            }

            if (this._issue.ResolutionDate.HasValue == false)
            {
                return(doneChange.Date);
            }

            var gap = doneChange.Date - this._issue.ResolutionDate.Value;

            if (gap.Duration() > TimeSpan.FromMinutes(5))
            {
                // can happen only if Jira's resolution date is out of sync
                return(this._issue.ResolutionDate);
            }

            return(this._issue.ResolutionDate != null
                ? doneChange.Date < this._issue.ResolutionDate.Value ? doneChange.Date : this._issue.ResolutionDate.Value
                : doneChange.Date);
        }
コード例 #2
0
        private JiraIssueChange PopulateSnapshot(JiraIssueChange change, JsonJiraIssueChangelogEventItem eventItem)
        {
            if ("status".Equals(eventItem.Field, StringComparison.OrdinalIgnoreCase))
            {
                var toId = int.Parse(eventItem.To, NumberStyles.Integer, CultureInfo.InvariantCulture);
                if (this._statuses.TryGetById(toId, out var toStatus))
                {
                    change.Status = toStatus;
                }
            }
            else if ("flagged".Equals(eventItem.Field, StringComparison.OrdinalIgnoreCase))
            {
                if (string.IsNullOrWhiteSpace(eventItem.From) && !string.IsNullOrWhiteSpace(eventItem.To))
                {
                    change.IsFlagged = true;
                }
                else if (!string.IsNullOrWhiteSpace(eventItem.From) && string.IsNullOrWhiteSpace(eventItem.To))
                {
                    change.IsFlagged = false;
                }
            }

            return(change);
        }
コード例 #3
0
 private bool IsRelevantChange(JiraIssueChange prevChange, JiraIssueChange nextChange)
 {
     return(prevChange.HasChanged(nextChange) || this._options.IsWorkDayPredicate(nextChange.Date));
 }