diff --git a/app/models/celery_script_settings_bag.rb b/app/models/celery_script_settings_bag.rb index 3f6085d64..036ef9f5e 100644 --- a/app/models/celery_script_settings_bag.rb +++ b/app/models/celery_script_settings_bag.rb @@ -7,6 +7,7 @@ module CeleryScriptSettingsBag # List of all celery script nodes that can be used as a varaible... ANY_VARIABLE = [:tool, :coordinate, :point, :identifier] + PLANT_STAGES = %w(planned planted harvested) ALLOWED_PIN_MODES = [DIGITAL = 0, ANALOG = 1] ALLOWED_PIN_TYPES = [Peripheral, Sensor].map(&:name) ALLOWED_RPC_NODES = %w(home emergency_lock emergency_unlock read_status diff --git a/app/serializers/point_serializer.rb b/app/serializers/point_serializer.rb index 3c7b35e0d..f677a880a 100644 --- a/app/serializers/point_serializer.rb +++ b/app/serializers/point_serializer.rb @@ -1,8 +1,10 @@ class PointSerializer < ActiveModel::Serializer attributes :id, :created_at, :updated_at, :device_id, :meta, :name, :pointer_type, :radius, :x, :y, :z + attribute :openfarm_slug, if: :plant? attribute :planted_at, if: :plant? + attribute :plant_stage, if: :plant? attribute :tool_id, if: :tool_slot? attribute :pullout_direction, if: :tool_slot? @@ -26,6 +28,10 @@ class PointSerializer < ActiveModel::Serializer object.pointer.planted_at end + def plant_stage + object.pointer.plant_stage + end + def pullout_direction object.pointer.pullout_direction end diff --git a/db/migrate/20180305170608_add_plant_stage_to_plants.rb b/db/migrate/20180305170608_add_plant_stage_to_plants.rb new file mode 100644 index 000000000..d1aa625bf --- /dev/null +++ b/db/migrate/20180305170608_add_plant_stage_to_plants.rb @@ -0,0 +1,6 @@ +class AddPlantStageToPlants < ActiveRecord::Migration[5.1] + def change + add_column :plants, :plant_stage, :string, limit: 10, default: "planned", + presence: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 816172667..bea30b406 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180301222052) do +ActiveRecord::Schema.define(version: 20180305170608) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -260,6 +260,7 @@ ActiveRecord::Schema.define(version: 20180301222052) do t.string "openfarm_slug", limit: 280, default: "50", null: false t.datetime "created_at" t.datetime "planted_at" + t.string "plant_stage", limit: 10, default: "planned" t.index ["created_at"], name: "index_plants_on_created_at" end diff --git a/latest_corpus.rb b/latest_corpus.rb index 0a4d9ba88..cac82184f 100755 --- a/latest_corpus.rb +++ b/latest_corpus.rb @@ -131,6 +131,7 @@ class CorpusEmitter result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES) result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINTER_TYPE) result.push(enum_type :AllowedPinTypes, CeleryScriptSettingsBag::ALLOWED_PIN_TYPES) + result.push(enum_type :PlantStage, CeleryScriptSettingsBag::PLANT_STAGES) File.open("latest_corpus.ts", "w") do |f| f.write(result.join.gsub("\n\n\n", "\n").gsub("\n\n", "\n").strip) diff --git a/package.json b/package.json index c417313b4..572438d84 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.1.0", "extract-text-webpack-plugin": "^3.0.1", - "farmbot": "5.4.0-rc3", + "farmbot": "5.4.0-rc4", "farmbot-toastr": "^1.0.3", "fastclick": "^1.0.6", "file-loader": "^1.1.5", diff --git a/webpack/__test_support__/fake_state/resources.ts b/webpack/__test_support__/fake_state/resources.ts index a64893f23..12e133066 100644 --- a/webpack/__test_support__/fake_state/resources.ts +++ b/webpack/__test_support__/fake_state/resources.ts @@ -98,6 +98,7 @@ export function fakePlant(): TaggedPlantPointer { id: idCounter++, name: "Strawberry Plant 1", pointer_type: "Plant", + plant_stage: "planned", x: 100, y: 200, z: 0, diff --git a/webpack/__test_support__/resource_index_builder.ts b/webpack/__test_support__/resource_index_builder.ts index 6df403a84..a8c314766 100644 --- a/webpack/__test_support__/resource_index_builder.ts +++ b/webpack/__test_support__/resource_index_builder.ts @@ -128,7 +128,6 @@ const tr7: TaggedPoint = { "id": 1392, "created_at": "2017-05-24T20:41:19.804Z", "updated_at": "2017-05-24T20:41:19.804Z", - // "device_id": 415, "meta": { }, @@ -138,7 +137,8 @@ const tr7: TaggedPoint = { "x": 347, "y": 385, "z": 0, - "openfarm_slug": "radish" + "openfarm_slug": "radish", + "plant_stage": "planned" }, "uuid": "Point.1392.6" }; @@ -159,7 +159,8 @@ const tr8: TaggedPoint = { "x": 727, "y": 376, "z": 0, - "openfarm_slug": "garlic" + "openfarm_slug": "garlic", + "plant_stage": "planned" }, "uuid": "Point.1393.7" }; @@ -331,7 +332,7 @@ export let FAKE_RESOURCES: TaggedResource[] = [tr1, fakeDevice(), tr2, tr3, tr4, export function buildResourceIndex(resources: TaggedResource[] = FAKE_RESOURCES, - state = emptyState()) { + state = emptyState()) { const KIND: keyof TaggedResource = "kind"; // Safety first, kids. return _(resources) .groupBy(KIND) diff --git a/webpack/farm_designer/plant.ts b/webpack/farm_designer/plant.ts index f809f8f10..01dac2c0e 100644 --- a/webpack/farm_designer/plant.ts +++ b/webpack/farm_designer/plant.ts @@ -16,6 +16,7 @@ export function Plant(options: PlantOptions): PlantPointer { y: (options.y || 0), z: 0, radius: (options.radius || DEFAULT_PLANT_RADIUS), - openfarm_slug + openfarm_slug, + plant_stage: "planned" }; } diff --git a/webpack/interfaces.ts b/webpack/interfaces.ts index f5dd6c115..ac27c7b66 100644 --- a/webpack/interfaces.ts +++ b/webpack/interfaces.ts @@ -1,7 +1,7 @@ import { AuthState } from "./auth/interfaces"; import { ConfigState } from "./config/interfaces"; import { BotState } from "./devices/interfaces"; -import { Color as FarmBotJsColor, ALLOWED_MESSAGE_TYPES } from "farmbot"; +import { Color as FarmBotJsColor, ALLOWED_MESSAGE_TYPES, PlantStage } from "farmbot"; import { DraggableState } from "./draggable/interfaces"; import { PeripheralState } from "./controls/peripherals/interfaces"; import { RestResources } from "./resources/interfaces"; @@ -108,7 +108,6 @@ interface BasePoint { x: number; y: number; z: number; - // device_id: number; pointer_id?: number | undefined; meta: { [key: string]: (string | undefined) }; name: string; @@ -118,6 +117,7 @@ export interface PlantPointer extends BasePoint { openfarm_slug: string; pointer_type: "Plant"; planted_at?: string; + plant_stage: PlantStage; } export enum ToolPulloutDirection { diff --git a/webpack/sequences/step_tiles/tile_move_absolute/test_helpers.ts b/webpack/sequences/step_tiles/tile_move_absolute/test_helpers.ts index 25bf41731..3af2a8739 100644 --- a/webpack/sequences/step_tiles/tile_move_absolute/test_helpers.ts +++ b/webpack/sequences/step_tiles/tile_move_absolute/test_helpers.ts @@ -16,7 +16,8 @@ export function fakeResourceIndex(): ResourceIndex { "x": 1, "y": 2, "z": 3, - "openfarm_slug": "garlic" + "openfarm_slug": "garlic", + "plant_stage": "planned" }, "uuid": "plant" }, diff --git a/yarn.lock b/yarn.lock index 0522b2e00..e23023251 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2258,9 +2258,9 @@ farmbot-toastr@^1.0.0, farmbot-toastr@^1.0.3: farmbot-toastr "^1.0.0" typescript "^2.3.4" -farmbot@5.4.0-rc3: - version "5.4.0-rc3" - resolved "https://registry.yarnpkg.com/farmbot/-/farmbot-5.4.0-rc3.tgz#5d3024f5234d7b22ebe77867cd1edb0e7e1d577e" +farmbot@5.4.0-rc4: + version "5.4.0-rc4" + resolved "https://registry.yarnpkg.com/farmbot/-/farmbot-5.4.0-rc4.tgz#478275c12875afcbb8e88a970c449f8c911dce0a" dependencies: mqtt "2.15.0" typescript "^2.4.2"