mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 21:34:59 +00:00
improve precision, tests
This commit is contained in:
parent
ec39f018e2
commit
e9e51db9c7
2 changed files with 6 additions and 4 deletions
|
@ -97,12 +97,12 @@ class Analytics:
|
||||||
if not uuid_str:
|
if not uuid_str:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Convert percentage to hex threshold (1% = "04", 10% = "1a", etc)
|
# Convert percentage to hex threshold (1% = "04...", 10% = "1a...", etc)
|
||||||
# Using first 2 hex digits (0-ff) means each digit is 1/256 of the space
|
# Using first 6 hex digits
|
||||||
if percent == 0:
|
if percent == 0:
|
||||||
return False
|
return False
|
||||||
threshold = format(int(255 * percent / 100), "02x")
|
threshold = format(int(0xFFFFFF * percent / 100), "06x")
|
||||||
return uuid_str[:2] <= threshold
|
return uuid_str[:6] <= threshold
|
||||||
|
|
||||||
def get_data_file_path(self):
|
def get_data_file_path(self):
|
||||||
data_file = Path.home() / ".aider" / "analytics.json"
|
data_file = Path.home() / ".aider" / "analytics.json"
|
||||||
|
|
|
@ -113,6 +113,8 @@ def test_is_uuid_in_percentage():
|
||||||
# Test basic percentage thresholds
|
# Test basic percentage thresholds
|
||||||
assert analytics.is_uuid_in_percentage("00000000000000000000000000000000", 1) is True
|
assert analytics.is_uuid_in_percentage("00000000000000000000000000000000", 1) is True
|
||||||
assert analytics.is_uuid_in_percentage("01999000000000000000000000000000", 1) is True
|
assert analytics.is_uuid_in_percentage("01999000000000000000000000000000", 1) is True
|
||||||
|
assert analytics.is_uuid_in_percentage("02000000000000000000000000000000", 1) is True
|
||||||
|
assert analytics.is_uuid_in_percentage("02910000000000000000000000000001", 1) is False
|
||||||
assert analytics.is_uuid_in_percentage("03000000000000000000000000000000", 1) is False
|
assert analytics.is_uuid_in_percentage("03000000000000000000000000000000", 1) is False
|
||||||
assert analytics.is_uuid_in_percentage("ff000000000000000000000000000000", 1) is False
|
assert analytics.is_uuid_in_percentage("ff000000000000000000000000000000", 1) is False
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue