lint code
This commit is contained in:
@@ -147,7 +147,9 @@ class DatabaseManager:
|
||||
migrations_run.append("region")
|
||||
|
||||
if "region_name" not in columns:
|
||||
cursor.execute("ALTER TABLE ip_stats ADD COLUMN region_name VARCHAR(100)")
|
||||
cursor.execute(
|
||||
"ALTER TABLE ip_stats ADD COLUMN region_name VARCHAR(100)"
|
||||
)
|
||||
migrations_run.append("region_name")
|
||||
|
||||
if "timezone" not in columns:
|
||||
|
||||
@@ -41,7 +41,9 @@ def fetch_ip_geolocation(ip_address: str) -> Optional[Dict[str, Any]]:
|
||||
|
||||
# Check if the API call was successful
|
||||
if data.get("status") != "success":
|
||||
app_logger.warning(f"IP lookup failed for {ip_address}: {data.get('message')}")
|
||||
app_logger.warning(
|
||||
f"IP lookup failed for {ip_address}: {data.get('message')}"
|
||||
)
|
||||
return None
|
||||
|
||||
# Cache the result
|
||||
@@ -113,7 +115,7 @@ def fetch_blocklist_data(ip_address: str) -> Optional[Dict[str, Any]]:
|
||||
# Get the most recent result (first in list, sorted by record_added)
|
||||
most_recent = results[0]
|
||||
list_on = most_recent.get("list_on", {})
|
||||
|
||||
|
||||
app_logger.debug(f"Fetched blocklist data for {ip_address}")
|
||||
return list_on
|
||||
except requests.RequestException as e:
|
||||
|
||||
@@ -29,7 +29,7 @@ def main():
|
||||
try:
|
||||
# Fetch geolocation data using ip-api.com
|
||||
geoloc_data = extract_geolocation_from_ip(ip)
|
||||
|
||||
|
||||
# Fetch blocklist data from lcrawl API
|
||||
blocklist_data = fetch_blocklist_data(ip)
|
||||
|
||||
@@ -55,7 +55,7 @@ def main():
|
||||
list_on = blocklist_data
|
||||
else:
|
||||
list_on = {}
|
||||
|
||||
|
||||
# Add flags to list_on
|
||||
list_on["is_proxy"] = is_proxy
|
||||
list_on["is_hosting"] = is_hosting
|
||||
@@ -69,7 +69,9 @@ def main():
|
||||
sanitized_city = sanitize_for_storage(city, 100) if city else None
|
||||
sanitized_timezone = sanitize_for_storage(timezone, 50)
|
||||
sanitized_isp = sanitize_for_storage(isp, 100)
|
||||
sanitized_reverse = sanitize_for_storage(reverse, 255) if reverse else None
|
||||
sanitized_reverse = (
|
||||
sanitize_for_storage(reverse, 255) if reverse else None
|
||||
)
|
||||
sanitized_list_on = sanitize_dict(list_on, 100000)
|
||||
|
||||
db_manager.update_ip_rep_infos(
|
||||
|
||||
Reference in New Issue
Block a user