Skip to content

Commit

Permalink
Merge pull request #2462 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.9.6
  • Loading branch information
gabrielburnworth committed May 10, 2024
2 parents 49f8959 + a9775e7 commit d3d69ac
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 213 deletions.
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GEM
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.7)
bigdecimal (3.1.8)
builder (3.2.4)
bunny (2.22.0)
amq-protocol (~> 2.3, >= 2.3.1)
Expand All @@ -104,7 +104,7 @@ GEM
delayed_job_active_record (4.1.8)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
devise (4.9.3)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -170,12 +170,12 @@ GEM
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.49.0)
google-cloud-storage (1.51.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.33)
google-apis-storage_v1 (~> 0.37)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
Expand All @@ -189,7 +189,7 @@ GEM
hashdiff (1.1.0)
hashie (4.1.0)
httpclient (2.8.3)
i18n (1.14.4)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
jsonapi-renderer (0.2.2)
jwt (2.8.1)
Expand Down Expand Up @@ -220,14 +220,14 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
method_source (1.0.0)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.22.3)
multi_json (1.15.0)
multipart-post (2.4.0)
multipart-post (2.4.1)
mutations (0.9.1)
activesupport
net-imap (0.4.10)
net-imap (0.4.11)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -236,12 +236,12 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
nio4r (2.7.1)
nokogiri (1.16.3-x86_64-linux)
nio4r (2.7.3)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
os (1.1.4)
parser (3.3.0.5)
parser (3.3.1.0)
ast (~> 2.4.1)
racc
passenger (6.0.20)
Expand Down Expand Up @@ -308,7 +308,7 @@ GEM
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
request_store (1.6.0)
request_store (1.7.0)
rack (>= 1.4)
responders (3.1.1)
actionpack (>= 5.2)
Expand All @@ -325,7 +325,7 @@ GEM
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.2)
Expand Down Expand Up @@ -443,4 +443,4 @@ RUBY VERSION
ruby 3.1.4p223

BUNDLED WITH
2.5.7
2.5.10
1 change: 0 additions & 1 deletion app/mutations/devices/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Create < Mutations::Command
optional do
string :timezone
string :name
string :webcam_url
float :lat
float :lng
boolean :indoor
Expand Down
5 changes: 0 additions & 5 deletions app/mutations/devices/seeders/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ module ToolNames
SEED_TROUGH_2 = "Seed Trough 2"
end

# Stub plants ==============================
PLANT_FIXTURE_PATH =
"app/mutations/devices/seeders/plant_fixtures.yml"
PLANTS = YAML.load(File.read(PLANT_FIXTURE_PATH))

# Stub sequences ===========================
SEQUENCE_FIXTURE_PATH =
"app/mutations/devices/seeders/sequence_fixtures.yml"
Expand Down
47 changes: 44 additions & 3 deletions app/mutations/devices/seeders/demo_account_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,49 @@ def create_webcam_feed(product_line)
device: device })
end

def plants
PLANTS.map { |x| Points::Create.run!(x, device: device) }
def plants(product_line)
spinach_row_count = product_line.include?("xl") ? 28 : 13
spinach_col_count = product_line.include?("xl") ? 4 : 2
(0..(spinach_row_count - 1)).map do |i|
(0..(spinach_col_count - 1)).map do |j|
Points::Create.run!(device: device,
pointer_type: "Plant",
name: "Spinach",
openfarm_slug: "spinach",
plant_stage: "planned",
x: 400 + i * 200,
y: 100 + j * 200 + (j > 1 ? 2100 : 0),
z: 0)
end
end
broccoli_row_count = product_line.include?("xl") ? 9 : 4
broccoli_col_count = product_line.include?("xl") ? 3 : 1
(0..(broccoli_row_count - 1)).map do |i|
(0..(broccoli_col_count - 1)).map do |j|
Points::Create.run!(device: device,
pointer_type: "Plant",
name: "Broccoli",
openfarm_slug: "broccoli",
plant_stage: "planned",
x: 600 + i * 600,
y: 700 + j * 600 + (j > 0 ? 300 : 0),
z: 0)
end
end
beet_row_count = product_line.include?("xl") ? 57 : 27
beet_col_count = product_line.include?("xl") ? 2 : 2
(0..(beet_row_count - 1)).map do |i|
(0..(beet_col_count - 1)).map do |j|
Points::Create.run!(device: device,
pointer_type: "Plant",
name: "Beet",
openfarm_slug: "beet",
plant_stage: "planned",
x: 200 + i * 100,
y: 1100 + j * 100 + (j > 1 ? 200 : 0),
z: 0)
end
end
end

def point_groups_spinach
Expand Down Expand Up @@ -76,7 +117,7 @@ def point_groups_beet

def misc(product_line)
create_webcam_feed(product_line)
plants
plants(product_line)
point_groups_spinach
point_groups_broccoli
point_groups_beet
Expand Down
133 changes: 0 additions & 133 deletions app/mutations/devices/seeders/plant_fixtures.yml

This file was deleted.

2 changes: 1 addition & 1 deletion app/mutations/devices/unattended_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def eligible_devices(chan)
.where("fbos_configs.os_auto_update" => true)
.where(ota_hour_utc: [nil, Time.now.utc.hour])
.order("RANDOM()")
.limit(200)
.limit(50)
end

def latest_version(chan)
Expand Down
2 changes: 1 addition & 1 deletion app/mutations/images/generate_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def execute
"GoogleAccessId" => post_object[:GoogleAccessId] || HMM,
"file" => "REPLACE_THIS_WITH_A_BINARY_JPEG_FILE",
},
instructions: "Send a 'from-data' request to the URL provided." \
instructions: "Send a 'form-data' request to the URL provided. " \
"Then POST the resulting URL as an 'attachment_url' " \
"(json) to api/images/.",
}
Expand Down
2 changes: 1 addition & 1 deletion app/mutations/images/stub_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def execute
"GoogleAccessId" => "N/A",
"file" => "REPLACE_THIS_WITH_A_BINARY_JPEG_FILE",
},
instructions: "Send a 'from-data' request to the URL provided." \
instructions: "Send a 'form-data' request to the URL provided." \
"Then POST the resulting URL as an 'attachment_url' " \
"(json) to api/images/.",
}
Expand Down
12 changes: 12 additions & 0 deletions frontend/point_groups/criteria/__tests__/apply_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ describe("selectPointsByCriteria()", () => {
const result = selectPointsByCriteria(criteria, allPoints, now);
expect(result).toEqual([matchingPoint]);
});

it("doesn't match plant without planted date", () => {
const criteria = fakeCriteria();
criteria.day = { days_ago: 1, op: "<" };
const otherPoint = fakePlant();
otherPoint.body.planted_at = undefined;
otherPoint.body.created_at = "2020-01-20T20:00:00.000Z";
const allPoints = [otherPoint];
const now = moment("2020-02-20T20:00:00.000Z");
const result = selectPointsByCriteria(criteria, allPoints, now);
expect(result).toEqual([]);
});
});

describe("pointsSelectedByGroup()", () => {
Expand Down
10 changes: 6 additions & 4 deletions frontend/point_groups/criteria/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ const checkCriteria =
.map(([key, value]) => isNumber(value) &&
compare[criteriaKey](get(point.body, key), value)));
case "day":
const pointDate = moment(point.body.pointer_type == "Plant"
&& point.body.planted_at
if (dayCriteriaEmpty(criteria.day)) { return true; }
const maybePointDate = point.body.pointer_type == "Plant"
? point.body.planted_at
: point.body.created_at);
: point.body.created_at;
if (!maybePointDate) { return false; }
const pointDate = moment(maybePointDate);
const compareDate = moment(now)
.subtract(criteria.day.days_ago, "days");
const matchesDays = criteria.day.op == "<"
? pointDate.isAfter(compareDate)
: pointDate.isBefore(compareDate);
return matchesDays || dayCriteriaEmpty(criteria.day);
return matchesDays;
}
};

Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/fe.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ EXCLUDE = [
reason: "dependency needs",
version: "1.4.1",
},
{
packages: ["eslint"],
reason: "breaking changes in",
version: "9",
},
]

# Load package.json as JSON.
Expand Down
Loading

0 comments on commit d3d69ac

Please sign in to comment.