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.
-
#priority_list ⇒ Boolean
Whether this issue appears on the priority dashboard.
-
#priority_list_priority ⇒ Integer
Sort order on priority dashboard (-1 = unranked).
-
#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.
- #priority_list? ⇒ Boolean
- #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.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 170 def initialize super @priority_list = false @priority_list_priority = -1 @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?.
25 26 27 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 25 def approvals @approvals end |
#archived_at ⇒ Time?
Returns when the archive sweep tagged this issue as archived.
38 39 40 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 38 def archived_at @archived_at end |
#auto_complete ⇒ Boolean
Returns whether to auto-complete on deployment (default: true).
18 19 20 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 18 def auto_complete @auto_complete end |
#closed_by_inactivity ⇒ Boolean
Returns whether this issue was auto-closed by the inactivity sweep.
36 37 38 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 36 def closed_by_inactivity @closed_by_inactivity end |
#commit_sha ⇒ String?
Returns merged PR commit SHA for release tracking.
16 17 18 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 16 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.
22 23 24 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 22 def links @links end |
#next_reminder_at ⇒ Time?
Returns when the next reminder event should fire for this issue.
31 32 33 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 31 def next_reminder_at @next_reminder_at end |
#priority_list ⇒ Boolean
Returns whether this issue appears on the priority dashboard.
10 11 12 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 10 def priority_list @priority_list end |
#priority_list_priority ⇒ Integer
Returns sort order on priority dashboard (-1 = unranked).
12 13 14 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 12 def priority_list_priority @priority_list_priority end |
#reminder_days ⇒ Array<Integer>?
Returns per-issue override of config.reminder_days; applies to both waiting kinds.
34 35 36 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 34 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.
14 15 16 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 14 def visibility_allowlist @visibility_allowlist end |
#waiting_on_approval_at ⇒ Time?
Returns when the issue entered “waiting on approval” state.
29 30 31 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 29 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.
27 28 29 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 27 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
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 77 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) .priority_list = false .priority_list_priority = -1 .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)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 47 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] .priority_list = hash.fetch(:priority_list, false) .priority_list_priority = hash.fetch(:priority_list_priority, -1) .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
187 188 189 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 187 def auto_complete? !!auto_complete end |
#priority_list? ⇒ Boolean
192 193 194 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 192 def priority_list? !!priority_list end |
#responded? ⇒ Boolean
197 198 199 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 197 def responded? !responded_at.nil? end |
#to_h ⇒ Hash
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 219 def to_h super.merge( responded_at: format_time(responded_at), issues_url: issues_url, priority_list: priority_list, priority_list_priority: priority_list_priority, 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: format_time(waiting_on_user_at), waiting_on_approval_at: format_time(waiting_on_approval_at), next_reminder_at: format_time(next_reminder_at), reminder_days: reminder_days, closed_by_inactivity: closed_by_inactivity, archived_at: 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.
209 210 211 212 213 214 215 216 |
# File 'lib/plan_my_stuff/issue_metadata.rb', line 209 def visible_to?(user) return true if public? resolved = UserResolver.resolve(user) return true if UserResolver.support?(resolved) visibility_allowlist.include?(UserResolver.user_id(resolved)) end |