plan_my_stuff 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6561200ae8220464aa3e705f21ae4d6695a4c3ae3db222677bb1deddddcd37b7
4
- data.tar.gz: 98d519079e5c203741de10ce667341246d20335253033357a5d3ae8e1b48feee
3
+ metadata.gz: f4162f792a9b4fbc7cced8a9a91721c21d15010189cf38021b87d20d53dbcb56
4
+ data.tar.gz: 72c6220c9be50c083360357ba28f1cb7225c784ed9c8813430e24e9e27736f04
5
5
  SHA512:
6
- metadata.gz: 8c78d58f9322827d0483389f56dd82d02786929b851cfc6bf81bdc11973f7cdb06e3866b12c40054d4db71f44a24f5c817fd41213b374cf96eeec75e4c384b44
7
- data.tar.gz: 9b1464ab72de0568958a73d75bb79f4d7e4095bbebc9e97dcf5f97445c79eace14f83d65da99de36f61c10f5ca37e178e5ffb2ef59afa941cad8f49b3ba56be2
6
+ metadata.gz: af715bae691caff87d81935e140a3bc2d4af7ef49780686f85b8f145ce9e7a6ff32a6ea689c697a4bc6d193ca0612ff7147a850ea5088876282c4a6bf284ab26
7
+ data.tar.gz: 94d67d34bc302ceb3ec4fa815d5420f60323a9be1c6b4003af4948675861328d5c0ae74c7cd71031a9102c30af7e63a7586d72b64136263c865b7f3cdd46d8ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.27.0
4
+
5
+ ### Added
6
+
7
+ - `PlanMyStuff::Issue#mark_responded!(user)` - stamps `metadata.responded_at` on the first support-user engagement of
8
+ any kind. No-ops when the user is blank, not a support user, the issue isn't a PMS issue, or `responded_at` is
9
+ already set.
10
+
11
+ ### Changed
12
+
13
+ - `Pipeline.take!` and the `issues.assigned` webhook now stamp `metadata.responded_at` on first support engagement
14
+ (was previously only set by the first support comment) (closes #60).
15
+
3
16
  ## 0.26.0
4
17
 
5
18
  ### Added
@@ -91,6 +91,10 @@ module PlanMyStuff
91
91
  # GitHub already records the issue assignment (that's what triggered this webhook), so the gem does not
92
92
  # call +assign!+ on the project item -- that would clobber co-assignees on the underlying issue.
93
93
  #
94
+ # Regardless of pipeline state, +mark_responded!+ stamps +metadata.responded_at+ when a support user is the
95
+ # assignee -- including self-assigns to issues already in the pipeline. The method's own guards no-op for
96
+ # non-support assignees and already-responded issues.
97
+ #
94
98
  # @return [void]
95
99
  #
96
100
  def handle_issue_assigned
@@ -101,6 +105,14 @@ module PlanMyStuff
101
105
 
102
106
  return if assignee_login.blank?
103
107
 
108
+ repo = payload_params.dig(:repository, :full_name)
109
+ issue = PlanMyStuff::Issue.find(issue_number, repo: repo)
110
+ assignee_user = PlanMyStuff::UserResolver.from_github_login(assignee_login)
111
+
112
+ # Stamp before the already-in-pipeline early-return so a support user self-assigning to an
113
+ # already-taken issue still records a first response.
114
+ issue.mark_responded!(assignee_user)
115
+
104
116
  existing = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue_number)
105
117
  if existing.present?
106
118
  Rails.logger.info("[PlanMyStuff] Issue ##{issue_number} already in pipeline project, skipping")
@@ -108,9 +120,6 @@ module PlanMyStuff
108
120
  return
109
121
  end
110
122
 
111
- repo = payload_params.dig(:repository, :full_name)
112
- issue = PlanMyStuff::Issue.find(issue_number, repo: repo)
113
-
114
123
  if issue.approvals_required? && !issue.fully_approved?
115
124
  Rails.logger.info("[PlanMyStuff] Issue ##{issue_number} has pending approvals, skipping")
116
125
 
@@ -119,7 +128,7 @@ module PlanMyStuff
119
128
 
120
129
  number = PlanMyStuff::Pipeline.resolve_pipeline_project_number!
121
130
  project_item = PlanMyStuff::ProjectItem.create!(issue, project_number: number)
122
- PlanMyStuff::Pipeline.take!(project_item, user: PlanMyStuff::UserResolver.from_github_login(assignee_login))
131
+ PlanMyStuff::Pipeline.take!(project_item, user: assignee_user)
123
132
  end
124
133
 
125
134
  # Removes the issue from the pipeline project when the LAST assignee is removed. If any assignees remain,
@@ -91,7 +91,7 @@ module PlanMyStuff
91
91
  cache_writer: :write_comment,
92
92
  )
93
93
 
94
- mark_issue_responded_if_first_support_comment!(issue, resolved_user) unless skip_responded
94
+ issue.mark_responded!(resolved_user) unless skip_responded
95
95
 
96
96
  comment = build(result, issue: issue)
97
97
  PlanMyStuff::Notifications.instrument('comment_created', comment, user: resolved_user)
@@ -218,29 +218,6 @@ module PlanMyStuff
218
218
  :internal
219
219
  end
220
220
 
221
- # Sets responded_at on the issue metadata if this is the first support comment and the issue hasn't been
222
- # responded to yet.
223
- #
224
- # @param issue [PlanMyStuff::Issue] parent issue
225
- # @param user [Object, nil] resolved user object
226
- #
227
- # @return [void]
228
- #
229
- def mark_issue_responded_if_first_support_comment!(issue, user)
230
- return if user.nil?
231
-
232
- return unless PlanMyStuff::UserResolver.support?(user)
233
- return unless issue.pms_issue?
234
-
235
- return if issue.metadata.responded?
236
-
237
- PlanMyStuff::Issue.update!(
238
- number: issue.number,
239
- repo: issue.repo,
240
- metadata: { responded_at: PlanMyStuff.format_time(Time.now.utc) },
241
- )
242
- end
243
-
244
221
  # Mutates issue waiting state based on the comment's author. Support users with +waiting_on_reply: true+ enter
245
222
  # the issue into waiting-on-user state. Non-support users clear any active waiting-on-user state and
246
223
  # auto-reopen issues that were closed by the inactivity sweep.
@@ -886,6 +886,30 @@ module PlanMyStuff
886
886
  save!(user: user, skip_notification: skip_notification)
887
887
  end
888
888
 
889
+ # Stamps +metadata.responded_at+ on the first support-user engagement with this issue. Centralizes the guards so
890
+ # every engagement path (first support comment, +Pipeline.take!+, self-assign webhook) can funnel through one
891
+ # method. No-ops unless +user+ resolves to a support user on a PMS issue that hasn't been responded to yet.
892
+ #
893
+ # @param user [Object, nil] actor engaging with the issue (resolved via +PlanMyStuff::UserResolver+)
894
+ #
895
+ # @return [void]
896
+ #
897
+ def mark_responded!(user)
898
+ resolved = PlanMyStuff::UserResolver.resolve(user)
899
+ return if resolved.blank?
900
+
901
+ return unless PlanMyStuff::UserResolver.support?(resolved)
902
+ return unless pms_issue?
903
+
904
+ return if metadata.responded?
905
+
906
+ self.class.update!(
907
+ number: number,
908
+ repo: repo,
909
+ metadata: { responded_at: PlanMyStuff.format_time(Time.now.utc) },
910
+ )
911
+ end
912
+
889
913
  # Re-fetches this issue from GitHub and updates all local attributes.
890
914
  #
891
915
  # @return [self]
@@ -150,7 +150,8 @@ module PlanMyStuff
150
150
  locked_statuses.include?(project_item.status)
151
151
  end
152
152
 
153
- # Moves a project item to "Started".
153
+ # Moves a project item to "Started". When +user+ is a support user, also stamps +metadata.responded_at+ on the
154
+ # issue via +Issue#mark_responded!+ (a no-op if it's already responded to / not a PMS issue).
154
155
  #
155
156
  # @param project_item [PlanMyStuff::ProjectItem]
156
157
  # @param user [Object, nil] actor forwarded to the +pipeline_started.plan_my_stuff+ payload
@@ -162,6 +163,8 @@ module PlanMyStuff
162
163
  status = resolve_status_name(PlanMyStuff::Pipeline::Status::STARTED)
163
164
  result = project_item.move_to!(status)
164
165
 
166
+ project_item.issue.mark_responded!(user) if user.present?
167
+
165
168
  instrument(PlanMyStuff::Pipeline::Status::STARTED, project_item, user: user)
166
169
  result
167
170
  end
@@ -3,7 +3,7 @@
3
3
  module PlanMyStuff
4
4
  module VERSION
5
5
  MAJOR = 0
6
- MINOR = 26
6
+ MINOR = 27
7
7
  TINY = 0
8
8
 
9
9
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_my_stuff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance