Update auto_sync_channel to cast updates to respective workers
parent
003c3c8ebe
commit
33c0046fff
|
@ -22,6 +22,7 @@ defmodule FarmbotCore.Asset do
|
|||
RegimenInstance,
|
||||
Sequence
|
||||
}
|
||||
alias FarmbotCore.AssetSupervisor
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
|
@ -65,8 +66,10 @@ defmodule FarmbotCore.Asset do
|
|||
is almost certainly what you want.
|
||||
"""
|
||||
def update_fbos_config!(fbos_config \\ nil, params) do
|
||||
FbosConfig.changeset(fbos_config || fbos_config(), params)
|
||||
|> Repo.insert_or_update!()
|
||||
new_data =
|
||||
FbosConfig.changeset(fbos_config || fbos_config(), params)
|
||||
|> Repo.insert_or_update!()
|
||||
AssetSupervisor.cast_child(new_data, {:new_data, new_data})
|
||||
end
|
||||
|
||||
## End FbosConfig
|
||||
|
@ -81,6 +84,13 @@ defmodule FarmbotCore.Asset do
|
|||
Map.fetch!(firmware_config(), field)
|
||||
end
|
||||
|
||||
def update_firmware_config!(firmware_config \\ nil, params) do
|
||||
new_data =
|
||||
FirmwareConfig.changeset(firmware_config || firmware_config(), params)
|
||||
|> Repo.insert_or_update!()
|
||||
AssetSupervisor.cast_child(new_data, {:new_data, new_data})
|
||||
end
|
||||
|
||||
## End FirmwareConfig
|
||||
|
||||
## Begin RegimenInstance
|
||||
|
|
|
@ -145,12 +145,12 @@ defmodule FarmbotExt.AMQP.AutoSyncChannel do
|
|||
:ok
|
||||
|
||||
asset_kind == FbosConfig ->
|
||||
Repo.get_by!(FbosConfig, id: id)
|
||||
|> FbosConfig.changeset(params)
|
||||
|> Repo.update!()
|
||||
Asset.update_fbos_config!(params)
|
||||
:ok
|
||||
|
||||
asset_kind == FirmwareConfig ->
|
||||
raise("FIXME")
|
||||
Asset.update_firmware_config!(params)
|
||||
:ok
|
||||
|
||||
# TODO(Connor) make this use `sync_group0()`
|
||||
asset_kind in [FarmwareEnv, FarmwareInstallation] ->
|
||||
|
|
Loading…
Reference in New Issue