Drilling down deeper into isolating stale data bug

qa/10.0.0
Rick Carlino 2020-05-17 12:08:37 -05:00
parent c5b40d9b6d
commit 3b256f14f6
4 changed files with 21 additions and 10 deletions

View File

@ -1 +1 @@
10.0.0-rc36
10.0.0-rc37

View File

@ -5,6 +5,7 @@ defmodule FarmbotCore.Asset.Private do
_are_ stored in Farmbot's database.
"""
require Logger
require FarmbotCore.Logger
alias FarmbotCore.{Asset.Repo,
Asset.Private.LocalMeta,
@ -15,14 +16,28 @@ defmodule FarmbotCore.Asset.Private do
@doc "Lists `module` objects that still need to be POSTed to the API."
def list_local(module) do
Repo.all(from(data in module, where: is_nil(data.id)))
list = Repo.all(from(data in module, where: is_nil(data.id)))
Enum.map(list, fn item ->
if module == FarmbotCore.Asset.Point do
msg = "list_local: Point#{item.id}.y = #{item.y || "nil"}"
FarmbotCore.Logger.info(3, msg)
end
item
end)
end
@doc "Lists `module` objects that have a `local_meta` object"
def list_dirty(module) do
table = table(module)
q = from(lm in LocalMeta, where: lm.table == ^table, select: lm.asset_local_id)
Repo.all(from(data in module, join: lm in subquery(q)))
list = Repo.all(from(data in module, join: lm in subquery(q)))
Enum.map(list, fn item ->
if module == FarmbotCore.Asset.Point do
msg = "list_local: Point#{item.id}.y = #{item.y || "nil"}"
FarmbotCore.Logger.info(3, msg)
end
item
end)
end
def maybe_get_local_meta(asset, table) do

View File

@ -51,10 +51,6 @@ defmodule FarmbotExt.API.DirtyWorker do
end
def work(dirty, module) do
if module == FarmbotCore.Asset.Point do
FarmbotCore.Logger.info(3, "#{__MODULE__} Point#{dirty.id}.y = #{dirty.y}")
end
case http_request(dirty, module) do
# Valid data
{:ok, %{status: s, body: body}} when s > 199 and s < 300 ->

View File

@ -32,11 +32,11 @@ defmodule FarmbotOS.SysCalls.ResourceUpdate do
"Weed" => "weed"
}
def notify_user_of_updates(kind, params) do
def notify_user_of_updates(kind, params, id \\ nil) do
Enum.map(params, fn {k, v} ->
name = @friendly_names[kind] || kind
property = @friendly_names["#{k}"] || k
msg = "Setting #{name} #{property} to #{inspect(v)}"
msg = "Setting #{name} #{id} #{property} to #{inspect(v)}"
FarmbotCore.Logger.info(3, msg)
end)
end
@ -53,7 +53,7 @@ defmodule FarmbotOS.SysCalls.ResourceUpdate do
end
def update_resource(kind, id, params) when kind in @point_kinds do
notify_user_of_updates(kind, params)
notify_user_of_updates(kind, params, id)
params = do_handlebars(params)
point_update_resource(kind, id, params)
end