Minor formatting issues.
parent
02f16082b9
commit
aecb77b48a
|
@ -6,27 +6,28 @@ defmodule FarmbotCore.Asset do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias FarmbotCore.Asset.{
|
alias FarmbotCore.Asset.{
|
||||||
Repo,
|
CriteriaRetriever,
|
||||||
Device,
|
Device,
|
||||||
DeviceCert,
|
DeviceCert,
|
||||||
FarmwareEnv,
|
|
||||||
FirstPartyFarmware,
|
|
||||||
FarmwareInstallation,
|
|
||||||
FarmEvent,
|
FarmEvent,
|
||||||
|
FarmwareEnv,
|
||||||
|
FarmwareInstallation,
|
||||||
FbosConfig,
|
FbosConfig,
|
||||||
FirmwareConfig,
|
FirmwareConfig,
|
||||||
|
FirstPartyFarmware,
|
||||||
Peripheral,
|
Peripheral,
|
||||||
PinBinding,
|
PinBinding,
|
||||||
Point,
|
Point,
|
||||||
PointGroup,
|
PointGroup,
|
||||||
|
Private,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
Regimen,
|
Regimen,
|
||||||
RegimenInstance,
|
RegimenInstance,
|
||||||
Sequence,
|
Repo,
|
||||||
Sensor,
|
Sensor,
|
||||||
SensorReading,
|
SensorReading,
|
||||||
|
Sequence,
|
||||||
Tool,
|
Tool,
|
||||||
CriteriaRetriever
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alias FarmbotCore.AssetSupervisor
|
alias FarmbotCore.AssetSupervisor
|
||||||
|
@ -259,7 +260,6 @@ defmodule FarmbotCore.Asset do
|
||||||
# by default, not a merge action.
|
# by default, not a merge action.
|
||||||
# MORE NOTES: Mixed keys (symbol vs. string) will crash this FN.
|
# MORE NOTES: Mixed keys (symbol vs. string) will crash this FN.
|
||||||
# Let's just stringify everything...
|
# Let's just stringify everything...
|
||||||
IO.inspect(params, label: "===== ORIGINAL PARAMS")
|
|
||||||
new_meta = params[:meta] || params["meta"] || %{}
|
new_meta = params[:meta] || params["meta"] || %{}
|
||||||
old_meta = point.meta || %{}
|
old_meta = point.meta || %{}
|
||||||
updated_meta = Map.merge(old_meta, new_meta)
|
updated_meta = Map.merge(old_meta, new_meta)
|
||||||
|
@ -268,7 +268,6 @@ defmodule FarmbotCore.Asset do
|
||||||
|> Enum.map(fn {k, v} -> {"#{k}", v} end)
|
|> Enum.map(fn {k, v} -> {"#{k}", v} end)
|
||||||
|> Map.new()
|
|> Map.new()
|
||||||
|
|
||||||
IO.inspect(clean_params, label: "=========== CLEAN PARAMS")
|
|
||||||
Repo.get_by(Point, id: point.id)
|
Repo.get_by(Point, id: point.id)
|
||||||
|> Point.changeset(clean_params)
|
|> Point.changeset(clean_params)
|
||||||
|> Repo.update()
|
|> Repo.update()
|
||||||
|
|
|
@ -44,9 +44,7 @@ defmodule FarmbotExt.API.DirtyWorker do
|
||||||
def handle_info(:do_work, %{module: module} = state) do
|
def handle_info(:do_work, %{module: module} = state) do
|
||||||
(Private.list_dirty(module) ++ Private.list_local(module))
|
(Private.list_dirty(module) ++ Private.list_local(module))
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|> Enum.map(fn dirty ->
|
|> Enum.map(fn dirty -> work(dirty, module) end)
|
||||||
work(dirty, module)
|
|
||||||
end)
|
|
||||||
|
|
||||||
Process.send_after(self(), :do_work, @timeout)
|
Process.send_after(self(), :do_work, @timeout)
|
||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
|
@ -71,13 +69,15 @@ defmodule FarmbotExt.API.DirtyWorker do
|
||||||
# Invalid data, but the API didn't say why
|
# Invalid data, but the API didn't say why
|
||||||
{:ok, %{status: s, body: _body}} when s > 399 and s < 500 ->
|
{:ok, %{status: s, body: _body}} when s > 399 and s < 500 ->
|
||||||
FarmbotCore.Logger.error(2, "HTTP Error #{s}. #{inspect(dirty)}")
|
FarmbotCore.Logger.error(2, "HTTP Error #{s}. #{inspect(dirty)}")
|
||||||
|
|
||||||
module.changeset(dirty)
|
module.changeset(dirty)
|
||||||
|> Map.put(:valid?, false)
|
|> Map.put(:valid?, false)
|
||||||
|> handle_changeset(module)
|
|> handle_changeset(module)
|
||||||
|
|
||||||
# HTTP Error. (500, network error, timeout etc.)
|
# HTTP Error. (500, network error, timeout etc.)
|
||||||
error ->
|
error ->
|
||||||
FarmbotCore.Logger.error(2,
|
FarmbotCore.Logger.error(
|
||||||
|
2,
|
||||||
"[#{module} #{dirty.local_id} #{inspect(self())}] HTTP Error: #{module} #{
|
"[#{module} #{dirty.local_id} #{inspect(self())}] HTTP Error: #{module} #{
|
||||||
inspect(error)
|
inspect(error)
|
||||||
}"
|
}"
|
||||||
|
@ -99,7 +99,7 @@ defmodule FarmbotExt.API.DirtyWorker do
|
||||||
end)
|
end)
|
||||||
|> Enum.join("\n")
|
|> Enum.join("\n")
|
||||||
|
|
||||||
FarmbotCore.Logger.error(3, "Failed to sync: #{module} \n #{message}")
|
FarmbotCore.Logger.error(3, "Failed to sync: #{module} \n #{message}")
|
||||||
_ = Repo.delete!(data)
|
_ = Repo.delete!(data)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue