Refactor and enhance various components of the FINN real estate analysis tool
- Updated docker-compose files to use local data volumes for development. - Refactored analysis.py to improve code readability and performance, including changes to cache age calculations and hash computations. - Enhanced cache.py to ensure the database directory is created if it doesn't exist and improved SQL query formatting. - Modified cli.py to improve logging and statistics reporting for finn_ads. - Updated config.py to streamline environment variable handling. - Initialized the database eagerly in http_server.py to prevent runtime errors. - Refactored mcp_server.py to slim down data structures and improve response formatting for API calls. - Enhanced service.py to improve feedback handling and shortlist retrieval, ensuring enriched data is returned. - Updated recompute_analysis_cache.py for better SQL query formatting.
This commit is contained in:
+4
-2
@@ -356,14 +356,16 @@ def stats() -> None:
|
||||
|
||||
# Special checks for finn_ads
|
||||
cursor.execute(
|
||||
'SELECT COUNT(*) FROM finn_ads '
|
||||
"SELECT COUNT(*) FROM finn_ads "
|
||||
'WHERE json_extract(payload, "$.eiendom_unit_code") IS NOT NULL '
|
||||
'AND json_extract(payload, "$.eiendom_unit_code") != "null"'
|
||||
)
|
||||
ads_with_unit_code = cursor.fetchone()[0]
|
||||
if "finn_ads" in stats and stats["finn_ads"]["total_rows"] > 0:
|
||||
stats["finn_ads"]["with_eiendom_unit_code"] = ads_with_unit_code
|
||||
stats["finn_ads"]["pct_with_unit_code"] = round(100 * ads_with_unit_code / stats["finn_ads"]["total_rows"], 1)
|
||||
stats["finn_ads"]["pct_with_unit_code"] = round(
|
||||
100 * ads_with_unit_code / stats["finn_ads"]["total_rows"], 1
|
||||
)
|
||||
|
||||
# Get fetched_at date ranges
|
||||
for table in ["finn_ads", "eiendom_units", "similar_units"]:
|
||||
|
||||
Reference in New Issue
Block a user