2016-09-12 14:42:18 -06:00
|
|
|
unless Rails.env == "production"
|
2017-11-07 16:19:25 -07:00
|
|
|
ToolSlot.destroy_all
|
|
|
|
Tool.destroy_all
|
|
|
|
Point.destroy_all
|
2017-11-08 07:31:43 -07:00
|
|
|
LogDispatch.destroy_all
|
2017-11-07 16:19:25 -07:00
|
|
|
|
2017-11-06 16:54:52 -07:00
|
|
|
User.destroy_all
|
2017-07-28 08:47:15 -06:00
|
|
|
POINT_COUNT = 2
|
|
|
|
PLANT_COUNT = 2
|
2017-05-24 12:57:42 -06:00
|
|
|
DATE_RANGE_LO = 1..3
|
|
|
|
DATE_RANGE_HI = 3..8
|
2016-12-07 14:08:36 -07:00
|
|
|
ENV['MQTT_HOST'] = "blooper.io"
|
2017-12-06 07:12:14 -07:00
|
|
|
ENV['OS_UPDATE_SERVER'] = "http://non_legacy_update_url.com"
|
2017-05-22 06:53:31 -06:00
|
|
|
Point.destroy_all
|
2017-05-08 06:41:01 -06:00
|
|
|
Device.destroy_all
|
2017-05-08 06:27:08 -06:00
|
|
|
User.destroy_all
|
2017-02-16 13:50:13 -07:00
|
|
|
Users::Create.run!(name: "Administrator",
|
2017-07-28 08:47:15 -06:00
|
|
|
email: "farmbot@farmbot.io",
|
2017-02-16 13:50:13 -07:00
|
|
|
password: "password123",
|
|
|
|
password_confirmation: "password123",
|
|
|
|
agree_to_terms: true)
|
2017-07-28 08:47:15 -06:00
|
|
|
signed_tos = User.last
|
|
|
|
signed_tos.agreed_to_terms_at = nil
|
2017-10-17 14:39:50 -06:00
|
|
|
signed_tos.confirmed_at = Time.now
|
2017-07-28 08:47:15 -06:00
|
|
|
signed_tos.save(validate: false)
|
2017-02-14 14:03:18 -07:00
|
|
|
Users::Create.run!(name: "Administrator",
|
|
|
|
email: "admin@admin.com",
|
|
|
|
password: "password123",
|
|
|
|
password_confirmation: "password123",
|
|
|
|
agree_to_terms: true)
|
|
|
|
u = User.last
|
2017-10-17 14:39:50 -06:00
|
|
|
u.update_attributes(confirmed_at: Time.now)
|
2016-12-08 13:05:05 -07:00
|
|
|
Log.transaction do
|
2017-10-22 07:19:50 -06:00
|
|
|
FactoryBot.create_list(:log, 35, device: u.device)
|
2016-12-08 13:05:05 -07:00
|
|
|
end
|
2017-06-15 13:08:07 -06:00
|
|
|
[ "https://via.placeholder.com/350x250?text=Image%20Zero",
|
|
|
|
"https://i.imgur.com/XvFBGA4.jpg",
|
|
|
|
"https://via.placeholder.com/350x250?text=Image%20Two",
|
|
|
|
"https://i.imgur.com/XsFczCY.jpg",
|
|
|
|
"https://via.placeholder.com/350x250?text=Image%20Four"
|
2017-06-05 11:08:48 -06:00
|
|
|
].each do |url|
|
2017-03-06 11:48:50 -07:00
|
|
|
Images::Create.run!(attachment_url: url,
|
|
|
|
device: u.device,
|
2017-04-27 14:53:28 -06:00
|
|
|
meta: {x: rand(40...970),
|
|
|
|
y: rand(40...470),
|
2017-04-27 14:26:25 -06:00
|
|
|
z: rand(1...300)})
|
2017-01-26 16:27:23 -07:00
|
|
|
end
|
2017-05-24 12:57:42 -06:00
|
|
|
|
|
|
|
PLANT_COUNT.times do
|
2017-05-04 09:14:38 -06:00
|
|
|
Point.create(
|
2017-02-14 14:03:18 -07:00
|
|
|
device: u.device,
|
2017-04-27 14:53:28 -06:00
|
|
|
x: rand(40...970),
|
|
|
|
y: rand(40...470),
|
2017-03-14 22:58:43 -06:00
|
|
|
radius: rand(10...50),
|
2017-01-20 08:01:30 -07:00
|
|
|
name: Haikunator.haikunate,
|
2017-05-04 09:14:38 -06:00
|
|
|
pointer: Plant.new(
|
|
|
|
openfarm_slug: ["tomato", "carrot", "radish", "garlic"].sample
|
|
|
|
))
|
2017-01-20 08:01:30 -07:00
|
|
|
end
|
2017-05-24 12:57:42 -06:00
|
|
|
|
|
|
|
POINT_COUNT.times do
|
2017-02-07 12:26:01 -07:00
|
|
|
Point.create(
|
2017-02-14 14:03:18 -07:00
|
|
|
device: u.device,
|
2017-04-27 14:53:28 -06:00
|
|
|
x: rand(40...970) + rand(40...970),
|
|
|
|
y: rand(40...470) + rand(40...470),
|
2017-02-07 12:26:01 -07:00
|
|
|
z: 5,
|
2017-03-09 11:35:26 -07:00
|
|
|
radius: (rand(1...150) + rand(1...150)) / 20,
|
2017-05-22 08:00:05 -06:00
|
|
|
pointer: GenericPointer.new(),
|
2017-03-09 11:34:51 -07:00
|
|
|
meta: {
|
|
|
|
created_by: "plant-detection",
|
|
|
|
color: (Sequence::COLORS + [nil]).sample
|
|
|
|
})
|
2017-02-07 12:26:01 -07:00
|
|
|
end
|
2017-02-14 14:03:18 -07:00
|
|
|
|
|
|
|
s = Sequences::Create.run!(device: u.device,
|
|
|
|
name: "Goto 0, 0, 0",
|
|
|
|
body: [{kind:"move_absolute",args:{location:{kind:"coordinate", args:{x:0,
|
2017-11-29 12:50:17 -07:00
|
|
|
y:0, z:0}}, offset:{kind:"coordinate", args:{x:0, y:0, z:0}}, speed:100}}])
|
2017-03-08 16:00:12 -07:00
|
|
|
t = Tools::Create.run!(name: "Trench Digging Tool", device: u.device)
|
2017-03-03 15:58:24 -07:00
|
|
|
body_txt = File.read("spec/lib/celery_script/ast_fixture4.json")
|
2018-02-11 12:33:46 -07:00
|
|
|
.gsub("__SEQUENCE_ID__", s[:id].to_s)
|
2017-03-03 15:58:24 -07:00
|
|
|
.gsub("__TOOL_ID__", t.id.to_s)
|
2017-03-03 09:34:33 -07:00
|
|
|
Sequences::Create.run!(device: u.device,
|
|
|
|
name: "Every Node",
|
2017-03-03 15:58:24 -07:00
|
|
|
body: JSON.parse(body_txt))
|
2017-02-14 14:03:18 -07:00
|
|
|
Regimens::Create.run(device: u.device,
|
|
|
|
name:"Test Regimen 456",
|
|
|
|
color:"gray",
|
|
|
|
regimen_items: [
|
2018-02-11 12:33:46 -07:00
|
|
|
{time_offset:300000, sequence_id:s[:id]},
|
|
|
|
{time_offset:173100000, sequence_id:s[:id]},
|
|
|
|
{time_offset:345900000, sequence_id:s[:id]}
|
2017-02-14 14:03:18 -07:00
|
|
|
])
|
2017-03-26 16:39:08 -06:00
|
|
|
Peripherals::Create.run!(device: u.device, pin: 13, label: "LED")
|
2017-04-07 11:22:49 -06:00
|
|
|
2.times do
|
2017-06-15 09:55:31 -06:00
|
|
|
FarmEvents::Create.run!(
|
|
|
|
device: u.device,
|
|
|
|
start_time: Time.now + 1.hour,
|
|
|
|
end_time: Date.today + ([*(DATE_RANGE_HI)].sample).days,
|
|
|
|
time_unit: "daily",
|
|
|
|
repeat: [*(DATE_RANGE_LO)].sample,
|
|
|
|
executable_id: Sequence.where(device: u.device).order("RANDOM()").first.id,
|
|
|
|
executable_type: "Sequence")
|
2017-02-23 11:51:43 -07:00
|
|
|
end
|
2017-09-19 12:28:19 -06:00
|
|
|
WebcamFeeds::Create.run!(device: u.device,
|
|
|
|
name: "My Feed 1",
|
|
|
|
url: "https://nature.nps.gov/air/webcams/parks/yosecam/yose.jpg")
|
2017-03-08 16:00:12 -07:00
|
|
|
ts = ToolSlots::Create.run!(device: u.device,
|
|
|
|
tool_id: t.id,
|
|
|
|
name: "Slot One.",
|
|
|
|
x: 10,
|
|
|
|
y: 10,
|
|
|
|
z: 10)
|
2016-09-12 14:42:18 -06:00
|
|
|
end
|