commit
fe2666e768
|
@ -1,5 +1,14 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# 9.2.2
|
||||||
|
|
||||||
|
* Fix firmware locking error ("Can't perform X in Y state")
|
||||||
|
* Removal of dead code / legacy plus numerous unit test additions.
|
||||||
|
* Added coveralls test coverage reporter
|
||||||
|
* Unit test additions (+2.7% coverage :tada:)
|
||||||
|
* Updates to build instructions for third party developers
|
||||||
|
* Bug fix for criteria-based groups that have only one filter criteria.
|
||||||
|
|
||||||
# 9.2.1
|
# 9.2.1
|
||||||
|
|
||||||
* Improve firmware debug messages.
|
* Improve firmware debug messages.
|
||||||
|
|
|
@ -49,7 +49,7 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
|
||||||
needs_meta_filter = Repo.all(dynamic_query)
|
needs_meta_filter = Repo.all(dynamic_query)
|
||||||
# There we go. We have all the matching %Point{}s
|
# There we go. We have all the matching %Point{}s
|
||||||
search_matches = search_meta_fields(pg, needs_meta_filter)
|
search_matches = search_meta_fields(pg, needs_meta_filter)
|
||||||
# ...but there are duplicates. We can remove them via uniq_by:
|
# ...but there are duplicates. We can remove them via uniq_by:
|
||||||
Enum.uniq_by((search_matches ++ always_ok), fn p -> p.id end)
|
Enum.uniq_by((search_matches ++ always_ok), fn p -> p.id end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
|
||||||
if days == 0 do
|
if days == 0 do
|
||||||
{ pg, accum }
|
{ pg, accum }
|
||||||
else
|
else
|
||||||
|
|
||||||
op = day_criteria["op"] || "<"
|
op = day_criteria["op"] || "<"
|
||||||
time = Timex.shift(Timex.now(), days: -1 * days)
|
time = Timex.shift(Timex.now(), days: -1 * days)
|
||||||
|
|
||||||
{ pg, accum ++ [{"created_at", op, time}] }
|
{ pg, accum ++ [{"created_at", op, time}] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -159,14 +159,19 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
|
||||||
# NOT OK: Repo.query("SELECT foo WHERE bar IN $0", [[1, 2, 3]])
|
# NOT OK: Repo.query("SELECT foo WHERE bar IN $0", [[1, 2, 3]])
|
||||||
# OK: Repo.query("SELECT foo WHERE bar IN ($0, $1, $2)", [1, 2, 3])
|
# OK: Repo.query("SELECT foo WHERE bar IN ($0, $1, $2)", [1, 2, 3])
|
||||||
defp stage_3({sql, args}, {full_query, full_args, count0}) when is_list(args) do
|
defp stage_3({sql, args}, {full_query, full_args, count0}) when is_list(args) do
|
||||||
final = count0 + Enum.count(args) - 1
|
arg_count = Enum.count(args)
|
||||||
|
final = count0 + (arg_count - 1)
|
||||||
initial_state = {sql, count0}
|
initial_state = {sql, count0}
|
||||||
{next_sql, _} = Enum.reduce(args, initial_state, fn
|
{next_sql, _} =
|
||||||
(_, {sql, ^count0}) -> {sql <> " ($#{count0},", count0+1}
|
if arg_count == 1 do
|
||||||
(_, {sql, ^final}) -> {sql <> " $#{final})", final}
|
{sql <> " ($#{count0})", nil}
|
||||||
(_, {sql, count}) -> {sql <> " $#{count},", count+1}
|
else
|
||||||
end)
|
Enum.reduce(args, initial_state, fn
|
||||||
|
(_, {sql, ^count0}) -> {sql <> " ($#{count0},", count0+1}
|
||||||
|
(_, {sql, ^final}) -> {sql <> " $#{final})", final}
|
||||||
|
(_, {sql, count}) -> {sql <> " $#{count},", count+1}
|
||||||
|
end)
|
||||||
|
end
|
||||||
{full_query ++ [next_sql], full_args ++ [args], final + 1}
|
{full_query ++ [next_sql], full_args ++ [args], final + 1}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,23 @@ defmodule FarmbotCore.Asset.CriteriaRetrieverTest do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@simple_point_group %PointGroup{
|
||||||
|
point_ids: [],
|
||||||
|
sort_type: "xy_ascending",
|
||||||
|
criteria: %{
|
||||||
|
"day" => %{
|
||||||
|
"op" => "<",
|
||||||
|
"days_ago" => 0
|
||||||
|
},
|
||||||
|
"string_eq" => %{
|
||||||
|
"pointer_type" => ["Plant"]
|
||||||
|
},
|
||||||
|
"number_eq" => %{},
|
||||||
|
"number_lt" => %{},
|
||||||
|
"number_gt" => %{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Use this is a fake "Timex.now()" value when mocking.
|
# Use this is a fake "Timex.now()" value when mocking.
|
||||||
@now ~U[2222-12-10 02:22:22.222222Z]
|
@now ~U[2222-12-10 02:22:22.222222Z]
|
||||||
@five_days_ago ~U[2222-12-05 01:11:11.111111Z]
|
@five_days_ago ~U[2222-12-05 01:11:11.111111Z]
|
||||||
|
@ -90,6 +107,19 @@ defmodule FarmbotCore.Asset.CriteriaRetrieverTest do
|
||||||
pg
|
pg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "direct match on `pointer_type` via `string_eq`" do
|
||||||
|
Repo.delete_all(PointGroup)
|
||||||
|
Repo.delete_all(Point)
|
||||||
|
|
||||||
|
point!(%{id: 1, pointer_type: "Plant"})
|
||||||
|
point!(%{id: 2, pointer_type: "Weed"})
|
||||||
|
point!(%{id: 3, pointer_type: "ToolSlot"})
|
||||||
|
point!(%{id: 4, pointer_type: "GenericPointer"})
|
||||||
|
|
||||||
|
result = CriteriaRetriever.run(@simple_point_group)
|
||||||
|
assert Enum.count(result) == 1
|
||||||
|
end
|
||||||
|
|
||||||
test "run/1" do
|
test "run/1" do
|
||||||
expect(Timex, :now, fn -> @now end)
|
expect(Timex, :now, fn -> @now end)
|
||||||
pg = point_group_with_fake_points()
|
pg = point_group_with_fake_points()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
defmodule FarmbotCore.ProjectTest do
|
defmodule FarmbotCore.ProjectTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
@opts [cd: Path.join("c_src", "farmbot-arduino-firmware")]
|
# @opts [cd: Path.join("c_src", "farmbot-arduino-firmware")]
|
||||||
|
|
||||||
test "arduino_commit" do
|
test "arduino_commit" do
|
||||||
actual = FarmbotCore.Project.arduino_commit()
|
actual = FarmbotCore.Project.arduino_commit()
|
||||||
|
|
|
@ -22,14 +22,14 @@ defmodule FarmbotOS.Lua.Ext.FirmwareTest do
|
||||||
lua = "return"
|
lua = "return"
|
||||||
|
|
||||||
expect(FarmbotCeleryScript.SysCalls, :move_absolute, 4, fn
|
expect(FarmbotCeleryScript.SysCalls, :move_absolute, 4, fn
|
||||||
(1, _, _, _) -> :ok
|
1, _, _, _ -> :ok
|
||||||
(_, _, _, _) -> {:error, msg}
|
_, _, _, _ -> {:error, msg}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
assert {[true], ^lua} = Firmware.move_absolute([1,2,3,4], lua)
|
assert {[true], ^lua} = Firmware.move_absolute([1, 2, 3, 4], lua)
|
||||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7,8], lua)
|
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5, 6, 7, 8], lua)
|
||||||
assert {[true], ^lua} = Firmware.move_absolute([1,2,3], lua)
|
assert {[true], ^lua} = Firmware.move_absolute([1, 2, 3], lua)
|
||||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7], lua)
|
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5, 6, 7], lua)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find_home/2" do
|
test "find_home/2" do
|
||||||
|
|
Loading…
Reference in New Issue