Skip to content

Commit

Permalink
update fuzz location accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Jun 27, 2024
1 parent a6ca069 commit 994b44c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def forwarding_token

def truncate_and_fuzz_location!
if latitude && longitude
fuzz_decimal_places = 4
fuzz_decimal_places = 3
total_decimal_places = 5
lat_fuzz = self.precise_location ? 0.0 : (Random.rand * 1/10.0**fuzz_decimal_places)
long_fuzz = self.precise_location ? 0.0 : (Random.rand * 1/10.0**fuzz_decimal_places)
Expand Down
4 changes: 2 additions & 2 deletions spec/models/device_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
device.save
expect(device.latitude).not_to eq(0.12345)
expect(device.longitude).not_to eq(10.12345)
expect((device.latitude - 0.12345).abs.truncate(5)).to be <= 0.0001
expect((device.longitude - 10.12345).abs.truncate(5)).to be <= 0.0001
expect((device.latitude - 0.12345).abs.truncate(5)).to be <= 0.001
expect((device.longitude - 10.12345).abs.truncate(5)).to be <= 0.001
end
end
end
Expand Down

0 comments on commit 994b44c

Please sign in to comment.