Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied

ALTER TABLE "sys" ADD COLUMN IF NOT EXISTS space_config JSONB NOT NULL DEFAULT '{}'::jsonb;

-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back

ALTER TABLE "sys" DROP COLUMN IF EXISTS space_config;
15 changes: 15 additions & 0 deletions spec/control_system_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ module PlaceOS::Model
ids = data.map { |d| JSON.parse(d).as_h["id"].to_s }
ids.sort.should eq zone_ids.sort
end

it "#space_config" do
cs = Generator.control_system.save!
cs.space_config["enabled"] = false
cs.space_config["allow_recurrence_bookings"] = "disabled"
cs.space_config["threshold"] = 0.25
cs.space_config["temp"] = 50
cs.space_config["i64"] = 20_i64
cs.space_config["none"] = nil
cs.save

cs.space_config["enabled"].should be_false
cs.space_config["allow_recurrence_bookings"].should eq("disabled")
cs.space_config["threshold"].should eq 0.25
end
end

describe "validation" do
Expand Down
2 changes: 2 additions & 0 deletions src/placeos-models/control_system.cr
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module PlaceOS::Model
attribute signage_last_seen : Time = -> { 5.hours.ago }, converter: PlaceOS::Model::Timestamps::EpochConverter, type: "integer", format: "Int64", mass_assignment: false
belongs_to Playlist::Item, foreign_key: "playlist_item_id"

attribute space_config : Hash(String, String | Int32 | Int64 | Float64 | Bool | Nil) = {} of String => (String | Int32 | Int64 | Float64 | Bool | Nil)

def update_last_seen_time(item_id : String? = nil)
system_id = self.id.as(String)

Expand Down
Loading