Skip to content

Commit 1f93e98

Browse files
committed
Broadcasts#dispatched_at was not populated
Resolves SPONSOR-APP-3X https://rubykaigi.sentry.io/issues/7073106363/
1 parent 56aa693 commit 1f93e98

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

app/controllers/broadcasts_controller.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ def index
55
@conference = current_sponsorship.conference
66

77
@broadcast_deliveries = BroadcastDelivery
8-
.where(sponsorship: current_sponsorship)
9-
.joins(:broadcast)
10-
.merge(Broadcast.where(status: :sent))
118
.includes(:broadcast)
12-
.order('broadcasts.dispatched_at DESC')
9+
.where(sponsorship: current_sponsorship, broadcast: {status: :sent})
10+
.order(broadcast: {id: :desc})
1311
end
1412

1513
private

app/models/broadcast.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Broadcast < ApplicationRecord
1313
validates :title, presence: true
1414
validates :body, presence: true
1515

16-
def perform_later!
17-
self.update!(status: :pending)
16+
def perform_later!(now: Time.current)
17+
self.update!(status: :pending, dispatched_at: now)
1818
self.deliveries.each do |delivery|
1919
delivery.update!(status: :pending)
2020
DispatchBroadcastDeliveryJob.perform_later(delivery)

app/views/broadcasts/index.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
.card.text-dark.mb-3{id: "broadcast-#{delivery.broadcast.id}"}
2222
.card-header
2323
%strong= delivery.broadcast.title
24-
%small.text-muted.ml-2= l(delivery.broadcast.dispatched_at, format: :short)
24+
%small.text-muted.ml-2= l(delivery.broadcast.dispatched_at || delivery.broadcast.created_at , format: :short)
2525
.card-body
2626
= replace_template_variables(delivery.broadcast.html)

0 commit comments

Comments
 (0)