Module: PlanMyStuff::IssueExtractions::Waiting
- Included in:
- PlanMyStuff::Issue
- Defined in:
- lib/plan_my_stuff/issue_extractions/waiting.rb
Instance Method Summary collapse
-
#clear_waiting_on_user! ⇒ self
Clears the waiting-on-user state: removes the label, clears
metadata.waiting_on_user_at, and clearsmetadata.next_reminder_atunless a waiting-on-approval timer is still active. -
#enter_waiting_on_user!(user: nil) ⇒ self
Marks the issue as waiting on an end-user reply.
-
#reopen_by_reply!(comment:, user: nil) ⇒ self
Reopens an issue that was auto-closed by the inactivity sweep, clears
metadata.closed_by_inactivity, and emitsplan_my_stuff.issue.reopened_by_replycarrying the reopening comment.
Instance Method Details
#clear_waiting_on_user! ⇒ self
Clears the waiting-on-user state: removes the label, clears metadata.waiting_on_user_at, and clears metadata.next_reminder_at unless a waiting-on-approval timer is still active. No-ops if the issue is not currently waiting on a user reply.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/plan_my_stuff/issue_extractions/waiting.rb', line 39 def clear_waiting_on_user! label = PlanMyStuff.configuration.waiting_on_user_label return self if .waiting_on_user_at.nil? && labels.exclude?(label) PlanMyStuff::Label.remove!(issue: self, labels: [label]) if labels.include?(label) self.class.update!( number: number, repo: repo, metadata: { waiting_on_user_at: nil, next_reminder_at: .waiting_on_approval_at ? PlanMyStuff.format_time(.next_reminder_at) : nil, }, ) reload end |
#enter_waiting_on_user!(user: nil) ⇒ self
Marks the issue as waiting on an end-user reply. Sets metadata.waiting_on_user_at to now, (re)computes metadata.next_reminder_at, and adds the configured waiting_on_user_label to the issue. Called from Comment.create! when a support user posts a comment with waiting_on_reply: true, and from the Issues::WaitingsController toggle.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plan_my_stuff/issue_extractions/waiting.rb', line 15 def enter_waiting_on_user!(user: nil) now = Time.now.utc label = PlanMyStuff.configuration.waiting_on_user_label PlanMyStuff::Label.ensure!(repo: repo, name: label) PlanMyStuff::Label.add!(issue: self, labels: [label], user: user) if labels.exclude?(label) self.class.update!( number: number, repo: repo, metadata: { waiting_on_user_at: PlanMyStuff.format_time(now), next_reminder_at: format_next_reminder_at(from: now), }, ) reload end |
#reopen_by_reply!(comment:, user: nil) ⇒ self
Reopens an issue that was auto-closed by the inactivity sweep, clears metadata.closed_by_inactivity, and emits plan_my_stuff.issue.reopened_by_reply carrying the reopening comment. Does not emit the regular issue.reopened event - subscribers that specifically care about this flow subscribe to the dedicated event.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/plan_my_stuff/issue_extractions/waiting.rb', line 66 def reopen_by_reply!(comment:, user: nil) inactive_label = PlanMyStuff.configuration.user_inactive_label PlanMyStuff::Label.remove!(issue: self, labels: [inactive_label]) if labels.include?(inactive_label) self.class.update!( number: number, repo: repo, state: :open, metadata: { closed_by_inactivity: false }, ) reload PlanMyStuff::Notifications.instrument( 'issue.reopened_by_reply', self, user: user, comment: comment, ) self end |