Skip to content

Commit

Permalink
chore: avoid notification flood
Browse files Browse the repository at this point in the history
  • Loading branch information
lhguerra committed Nov 13, 2024
1 parent bba062a commit bc2ff67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/adapters/jira/jira_issue_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def read_assigned_responsibles(demand, history_date, responsible_name)
item_assignment.update(finish_time: nil)
else
item_assignment = demand.item_assignments.create(membership: membership, start_time: history_date)
demand_url = company_demand_url(demand.company, demand)
company_demand_url(demand.company, demand)

Slack::SlackNotificationService.instance.notify_item_assigned(item_assignment, demand_url)
# Slack::SlackNotificationService.instance.notify_item_assigned(item_assignment, demand_url)
end

item_assignment.id
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/slack/demand_slack_notifications_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def process_assignments(demand)

demand.item_assignments.reload.where(assignment_notified: false).each do |assignment|
demand_url = company_demand_url(demand.company, demand)
# Slack::SlackNotificationService.instance.notify_item_assigned(assignment, demand_url)
Slack::SlackNotificationService.instance.notify_item_assigned(assignment, demand_url)
ItemAssignment.transaction { assignment.update(assignment_notified: true) }
end
end
Expand Down
20 changes: 10 additions & 10 deletions spec/jobs/slack/demand_slack_notifications_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
end
end

# context 'with assignments' do
# it 'calls the notification method for the assignments not notified yet' do
# Fabricate :item_assignment, demand: demand, assignment_notified: false
# Fabricate :item_assignment, demand: demand, assignment_notified: false
# Fabricate :item_assignment, demand: demand, assignment_notified: true
#
# # expect_any_instance_of(Slack::SlackNotificationService).to receive(:notify_item_assigned).twice
# described_class.perform_now(team)
# end
# end
context 'with assignments' do
it 'calls the notification method for the assignments not notified yet' do
Fabricate :item_assignment, demand: demand, assignment_notified: false
Fabricate :item_assignment, demand: demand, assignment_notified: false
Fabricate :item_assignment, demand: demand, assignment_notified: true

expect_any_instance_of(Slack::SlackNotificationService).to receive(:notify_item_assigned).twice
described_class.perform_now(team)
end
end
end
end

0 comments on commit bc2ff67

Please sign in to comment.