From 994b44c9d12fa1c9802c2d2fd37b8ab9d5bdd2d3 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Thu, 27 Jun 2024 18:56:11 +0200 Subject: [PATCH] update fuzz location accuracy --- app/models/device.rb | 2 +- spec/models/device_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/device.rb b/app/models/device.rb index f4074a0f..bcfdb98b 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -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) diff --git a/spec/models/device_spec.rb b/spec/models/device_spec.rb index 2b857d04..7e865a50 100644 --- a/spec/models/device_spec.rb +++ b/spec/models/device_spec.rb @@ -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