mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 21:50:37 -05:00
Relate issues created together from an estimate
Every issue created in one batch from the estimate preview is now
related ("Related to") to every other issue in that batch. Relations
are added without journals, so no history entries or update emails
are generated; a relation that fails is logged and doesn't block
issue creation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
2 files changed
+19
-2
No files matched your search
@@ -16,6 +16,7 @@ module RedmineQboCalendar
|
||||
# - Subject = the line's description; estimated hours = the line's quantity
|
||||
# - Lines already turned into issues are shown but can't be created again
|
||||
# - Creation is all-or-nothing: if any issue fails validation, none are saved
|
||||
# - Issues created together are all related to each other
|
||||
class EstimateIssueBuilder
|
||||
include Redmine::I18n
|
||||
|
||||
@@ -105,6 +106,8 @@ module RedmineQboCalendar
|
||||
issue: issue
|
||||
)
|
||||
end
|
||||
|
||||
relate_issues(built.map(&:last))
|
||||
end
|
||||
|
||||
@errors.any? ? [] : built.map(&:last)
|
||||
@@ -154,6 +157,20 @@ module RedmineQboCalendar
|
||||
key.to_s
|
||||
end
|
||||
|
||||
# Relates every issue in the batch to every other one ("Related to"), since they're work on the
|
||||
# same estimate done at the same time. New issues have no open journal, so this adds no history
|
||||
# entries and sends no "issue updated" emails. A failed relation is logged, not fatal.
|
||||
def relate_issues(issues)
|
||||
issues.combination(2).each do |issue_from, issue_to|
|
||||
relation = IssueRelation.new(issue_from: issue_from, issue_to: issue_to,
|
||||
relation_type: IssueRelation::TYPE_RELATES)
|
||||
next if relation.save
|
||||
|
||||
Rails.logger.warn "[EstimateIssueBuilder] Could not relate ##{issue_from.id} and ##{issue_to.id}: " \
|
||||
"#{relation.errors.full_messages.join(', ')}"
|
||||
end
|
||||
end
|
||||
|
||||
def build_issue(proposal, row, project, author, allowed_trackers, custom_field_values)
|
||||
issue = Issue.new(project: project, author: author)
|
||||
issue.tracker = allowed_trackers.detect { |t| t.id == row['tracker_id'].to_i }
|
||||
|
||||
Reference in new issue
Block a user