Class: PlanMyStuff::IssueMetadata
- Inherits:
-
BaseMetadata
- Object
- BaseMetadata
- PlanMyStuff::IssueMetadata
- Defined in:
- lib/plan_my_stuff/issue_metadata.rb
Constant Summary
Constants inherited from BaseMetadata
Instance Attribute Summary collapse
-
#approvals ⇒ Array<PlanMyStuff::Approval>
Manager approvals required on this issue.
-
#archived_at ⇒ Time?
When the archive sweep tagged this issue as archived.
-
#auto_complete ⇒ Boolean
Whether to auto-complete on deployment (default: true).
-
#closed_by_inactivity ⇒ Boolean
Whether this issue was auto-closed by the inactivity sweep.
-
#commit_sha ⇒ String?
Merged PR commit SHA for release tracking.
-
#issues_url ⇒ String?
User-facing URL in the consuming app.
-
#links ⇒ Array<PlanMyStuff::Link>
Metadata-backed issue relationships.
-
#next_reminder_at ⇒ Time?
When the next reminder event should fire for this issue.
-
#reminder_days ⇒ Array<Integer>?
Per-issue override of
config.reminder_days; applies to both waiting kinds. -
#responded_at ⇒ Time?
First support action timestamp, nil until set.
-
#visibility_allowlist ⇒ Array<Integer>
User IDs of non-support users allowed to view internal comments.
-
#waiting_on_approval_at ⇒ Time?
When the issue entered “waiting on approval” state.
-
#waiting_on_user_at ⇒ Time?
When the issue entered “waiting on user reply” state.
Attributes inherited from BaseMetadata
#app_name, #created_by, #custom_fields, #gem_version, #rails_env, #schema_version, #visibility
Class Method Summary collapse
-
.build(user:, visibility: 'public', custom_fields: {}) ⇒ IssueMetadata
Builds a new IssueMetadata for issue creation, auto-filling gem defaults.
-
.from_hash(hash) ⇒ IssueMetadata
Builds an IssueMetadata from a parsed hash (e.g. from MetadataParser).
Instance Method Summary collapse
- #auto_complete? ⇒ Boolean
-
#initialize ⇒ IssueMetadata
constructor
A new instance of IssueMetadata.
- #responded? ⇒ Boolean
- #to_h ⇒ Hash
-
#visible_to?(user) ⇒ Boolean
Checks whether a user can see this issue’s internal content.
Methods inherited from BaseMetadata
#internal?, #public?, #to_json, #validate_custom_fields!
Constructor Details
#initialize ⇒ IssueMetadata
Returns a new instance of IssueMetadata.
162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 162 def initialize super @visibility_allowlist = [] @auto_complete = true @links = [] @approvals = [] @waiting_on_user_at = nil @waiting_on_approval_at = nil @next_reminder_at = nil @reminder_days = nil @closed_by_inactivity = false @archived_at = nil end |
Instance Attribute Details
#approvals ⇒ Array<PlanMyStuff::Approval>
Returns manager approvals required on this issue. See Issue.request_approvals! and Issue#fully_approved?.
21 22 23 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 21 def approvals @approvals end |
#archived_at ⇒ Time?
Returns when the archive sweep tagged this issue as archived.
34 35 36 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 34 def archived_at @archived_at end |
#auto_complete ⇒ Boolean
Returns whether to auto-complete on deployment (default: true).
14 15 16 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 14 def auto_complete @auto_complete end |
#closed_by_inactivity ⇒ Boolean
Returns whether this issue was auto-closed by the inactivity sweep.
32 33 34 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 32 def closed_by_inactivity @closed_by_inactivity end |
#commit_sha ⇒ String?
Returns merged PR commit SHA for release tracking.
12 13 14 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 12 def commit_sha @commit_sha end |
#issues_url ⇒ String?
Returns user-facing URL in the consuming app.
8 9 10 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 8 def issues_url @issues_url end |
#links ⇒ Array<PlanMyStuff::Link>
Returns metadata-backed issue relationships. Only :related links live here; native relationships (blocking, parent, sub_ticket, duplicate_of) live on GitHub.
18 19 20 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 18 def links @links end |
#next_reminder_at ⇒ Time?
Returns when the next reminder event should fire for this issue.
27 28 29 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 27 def next_reminder_at @next_reminder_at end |
#reminder_days ⇒ Array<Integer>?
Returns per-issue override of config.reminder_days; applies to both waiting kinds.
30 31 32 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 30 def reminder_days @reminder_days end |
#responded_at ⇒ Time?
Returns first support action timestamp, nil until set.
6 7 8 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 6 def responded_at @responded_at end |
#visibility_allowlist ⇒ Array<Integer>
Returns user IDs of non-support users allowed to view internal comments.
10 11 12 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 10 def visibility_allowlist @visibility_allowlist end |
#waiting_on_approval_at ⇒ Time?
Returns when the issue entered “waiting on approval” state.
25 26 27 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 25 def waiting_on_approval_at @waiting_on_approval_at end |
#waiting_on_user_at ⇒ Time?
Returns when the issue entered “waiting on user reply” state.
23 24 25 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 23 def waiting_on_user_at @waiting_on_user_at end |
Class Method Details
.build(user:, visibility: 'public', custom_fields: {}) ⇒ IssueMetadata
Builds a new IssueMetadata for issue creation, auto-filling gem defaults
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 71 def build(user:, visibility: 'public', custom_fields: {}) = new apply_common_build( , user: user, visibility: visibility, custom_fields_data: custom_fields, custom_fields_schema: PlanMyStuff.configuration.custom_fields_for(:issue), ) .responded_at = nil .issues_url = build_issues_url(PlanMyStuff.configuration) .visibility_allowlist = [] .commit_sha = nil .auto_complete = true .links = [] .approvals = [] .waiting_on_user_at = nil .waiting_on_approval_at = nil .next_reminder_at = nil .reminder_days = nil .closed_by_inactivity = false .archived_at = nil end |
.from_hash(hash) ⇒ IssueMetadata
Builds an IssueMetadata from a parsed hash (e.g. from MetadataParser)
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 43 def from_hash(hash) = new apply_common_from_hash(, hash, PlanMyStuff.configuration.custom_fields_for(:issue)) .responded_at = parse_time(hash[:responded_at]) .issues_url = hash[:issues_url] .visibility_allowlist = Array.wrap(hash[:visibility_allowlist]) .commit_sha = hash[:commit_sha] .auto_complete = hash.fetch(:auto_complete, true) .links = normalize_links(hash[:links]) .approvals = normalize_approvals(hash[:approvals]) .waiting_on_user_at = parse_time(hash[:waiting_on_user_at]) .waiting_on_approval_at = parse_time(hash[:waiting_on_approval_at]) .next_reminder_at = parse_time(hash[:next_reminder_at]) .reminder_days = normalize_reminder_days(hash[:reminder_days]) .closed_by_inactivity = hash.fetch(:closed_by_inactivity, false) .archived_at = parse_time(hash[:archived_at]) end |
Instance Method Details
#auto_complete? ⇒ Boolean
177 178 179 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 177 def auto_complete? !!auto_complete end |
#responded? ⇒ Boolean
182 183 184 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 182 def responded? !responded_at.nil? end |
#to_h ⇒ Hash
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 204 def to_h super.merge( responded_at: PlanMyStuff.format_time(responded_at), issues_url: issues_url, visibility_allowlist: visibility_allowlist, commit_sha: commit_sha, auto_complete: auto_complete, links: links.map(&:to_h), approvals: approvals.map(&:to_h), waiting_on_user_at: PlanMyStuff.format_time(waiting_on_user_at), waiting_on_approval_at: PlanMyStuff.format_time(waiting_on_approval_at), next_reminder_at: PlanMyStuff.format_time(next_reminder_at), reminder_days: reminder_days, closed_by_inactivity: closed_by_inactivity, archived_at: PlanMyStuff.format_time(archived_at), ) end |
#visible_to?(user) ⇒ Boolean
Checks whether a user can see this issue’s internal content. Public issues are always visible. Internal issues are visible if the user is support staff or their ID is in the visibility_allowlist.
194 195 196 197 198 199 200 201 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 194 def visible_to?(user) return true if public? resolved = PlanMyStuff::UserResolver.resolve(user) return true if PlanMyStuff::UserResolver.support?(resolved) visibility_allowlist.include?(PlanMyStuff::UserResolver.user_id(resolved)) end |