2019-03-05 11:09:15 -07:00
|
|
|
defmodule FarmbotCore.Asset.Point do
|
2018-10-29 10:33:52 -06:00
|
|
|
@moduledoc """
|
|
|
|
Points are data around an x,y,z
|
|
|
|
"""
|
2019-03-05 11:09:15 -07:00
|
|
|
use FarmbotCore.Asset.Schema, path: "/api/points"
|
2018-10-29 10:33:52 -06:00
|
|
|
|
|
|
|
schema "points" do
|
|
|
|
field(:id, :id)
|
|
|
|
|
2019-03-05 11:09:15 -07:00
|
|
|
has_one(:local_meta, FarmbotCore.Asset.Private.LocalMeta,
|
2018-10-29 10:33:52 -06:00
|
|
|
on_delete: :delete_all,
|
|
|
|
references: :local_id,
|
|
|
|
foreign_key: :asset_local_id
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:meta, :map)
|
|
|
|
field(:name, :string)
|
|
|
|
field(:plant_stage, :string)
|
|
|
|
field(:planted_at, :utc_datetime)
|
|
|
|
field(:pointer_type, :string)
|
|
|
|
field(:radius, :float)
|
|
|
|
field(:x, :float)
|
|
|
|
field(:y, :float)
|
|
|
|
field(:z, :float)
|
2018-12-04 13:20:09 -07:00
|
|
|
field(:tool_id, :integer)
|
2019-09-26 11:05:53 -06:00
|
|
|
field(:discarded_at, :utc_datetime)
|
2020-02-18 17:33:17 -07:00
|
|
|
field(:gantry_mounted, :boolean, default: false)
|
2018-11-19 12:32:54 -07:00
|
|
|
field(:monitor, :boolean, default: true)
|
2018-10-29 10:33:52 -06:00
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
view point do
|
|
|
|
%{
|
|
|
|
id: point.id,
|
|
|
|
meta: point.meta,
|
2019-06-03 14:41:32 -06:00
|
|
|
name: point.name,
|
2018-10-29 10:33:52 -06:00
|
|
|
plant_stage: point.plant_stage,
|
2019-06-03 14:41:32 -06:00
|
|
|
planted_at: point.planted_at,
|
2018-10-29 10:33:52 -06:00
|
|
|
pointer_type: point.pointer_type,
|
2019-06-03 14:41:32 -06:00
|
|
|
radius: point.radius,
|
2018-12-04 13:20:09 -07:00
|
|
|
tool_id: point.tool_id,
|
2019-09-26 11:05:53 -06:00
|
|
|
discarded_at: point.discarded_at,
|
2018-10-29 10:33:52 -06:00
|
|
|
x: point.x,
|
|
|
|
y: point.y,
|
|
|
|
z: point.z
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def changeset(point, params \\ %{}) do
|
|
|
|
point
|
|
|
|
|> cast(params, [
|
|
|
|
:id,
|
|
|
|
:meta,
|
|
|
|
:name,
|
|
|
|
:plant_stage,
|
|
|
|
:planted_at,
|
|
|
|
:pointer_type,
|
|
|
|
:radius,
|
|
|
|
:x,
|
|
|
|
:y,
|
|
|
|
:z,
|
2018-12-04 13:20:09 -07:00
|
|
|
:tool_id,
|
2019-09-26 11:05:53 -06:00
|
|
|
:discarded_at,
|
2018-11-19 12:32:54 -07:00
|
|
|
:monitor,
|
2018-10-29 10:33:52 -06:00
|
|
|
:created_at,
|
|
|
|
:updated_at
|
|
|
|
])
|
|
|
|
|> validate_required([])
|
|
|
|
end
|
|
|
|
end
|