Spaces:
Running
on
T4
Running
on
T4
reverting commit 39487d51803085764e...
Browse files- auditqa/utils.py +9 -10
auditqa/utils.py
CHANGED
|
@@ -154,20 +154,19 @@ def get_client_location(ip_address) -> dict | None:
|
|
| 154 |
if response.status_code == 200:
|
| 155 |
data = response.json()
|
| 156 |
# Add random noise between -0.01 and 0.01 degrees (roughly ±1km)
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
|
| 163 |
return {
|
| 164 |
'city': data.get('city'),
|
| 165 |
'region': data.get('region'),
|
| 166 |
-
'country': data.get('country_name')
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
#}
|
| 171 |
elif response.status_code == 429:
|
| 172 |
logging.warning(f"Rate limit exceeded. Response: {response.text}")
|
| 173 |
return None
|
|
|
|
| 154 |
if response.status_code == 200:
|
| 155 |
data = response.json()
|
| 156 |
# Add random noise between -0.01 and 0.01 degrees (roughly ±1km)
|
| 157 |
+
lat = data.get('latitude')
|
| 158 |
+
lon = data.get('longitude')
|
| 159 |
+
if lat is not None and lon is not None:
|
| 160 |
+
lat += random.uniform(-0.01, 0.01)
|
| 161 |
+
lon += random.uniform(-0.01, 0.01)
|
| 162 |
|
| 163 |
return {
|
| 164 |
'city': data.get('city'),
|
| 165 |
'region': data.get('region'),
|
| 166 |
+
'country': data.get('country_name'),
|
| 167 |
+
'latitude': lat,
|
| 168 |
+
'longitude': lon
|
| 169 |
+
}
|
|
|
|
| 170 |
elif response.status_code == 429:
|
| 171 |
logging.warning(f"Rate limit exceeded. Response: {response.text}")
|
| 172 |
return None
|