mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-09 08:47:11 -05:00
25 lines
460 B
Ruby
25 lines
460 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Trips::CalculateCountriesJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(trip_id)
|
|
trip = Trip.find(trip_id)
|
|
|
|
trip.calculate_countries
|
|
trip.save!
|
|
|
|
broadcast_update(trip)
|
|
end
|
|
|
|
private
|
|
|
|
def broadcast_update(trip)
|
|
Turbo::StreamsChannel.broadcast_update_to(
|
|
"trip_#{trip.id}",
|
|
target: "trip_countries",
|
|
partial: "trips/countries",
|
|
locals: { trip: trip }
|
|
)
|
|
end
|
|
end
|