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:
Ole
2026-05-29 15:17:11 +00:00
parent 55d93894ac
commit eb95b98111
10 changed files with 295 additions and 343 deletions
+3 -9
View File
@@ -14,9 +14,7 @@ FINN_USER_AGENT = os.getenv("FINN_USER_AGENT", "personal-finn-eiendom-analyzer/0
# Cache TTLs (refactor v2)
# Structural data (address, area, year, etc.) changes rarely; long TTL
FINN_CACHE_TTL_AD_STRUCTURAL_DAYS = int(
os.getenv("FINN_CACHE_TTL_AD_STRUCTURAL_DAYS", "30")
)
FINN_CACHE_TTL_AD_STRUCTURAL_DAYS = int(os.getenv("FINN_CACHE_TTL_AD_STRUCTURAL_DAYS", "30"))
# Price/status changes frequently; short TTL for lightweight verification
FINN_CACHE_TTL_AD_PRICE_HOURS = int(os.getenv("FINN_CACHE_TTL_AD_PRICE_HOURS", "6"))
# Search pages/cards also TTL-based (content changes with added/removed listings)
@@ -27,12 +25,8 @@ EIENDOM_NO_ENABLED = os.getenv("EIENDOM_NO_ENABLED", "true").lower() == "true"
EIENDOM_NO_BASE_URL = os.getenv("EIENDOM_NO_BASE_URL", "https://api.eiendom.no/api/v1")
EIENDOM_NO_REQUEST_DELAY_SECONDS = float(os.getenv("EIENDOM_NO_REQUEST_DELAY_SECONDS", "1"))
# Structural data (lat, lng, property_type) has long TTL; estimates have shorter TTL
EIENDOM_NO_CACHE_TTL_STRUCTURAL_DAYS = int(
os.getenv("EIENDOM_NO_CACHE_TTL_STRUCTURAL_DAYS", "30")
)
EIENDOM_NO_CACHE_TTL_ESTIMATE_DAYS = int(
os.getenv("EIENDOM_NO_CACHE_TTL_ESTIMATE_DAYS", "7")
)
EIENDOM_NO_CACHE_TTL_STRUCTURAL_DAYS = int(os.getenv("EIENDOM_NO_CACHE_TTL_STRUCTURAL_DAYS", "30"))
EIENDOM_NO_CACHE_TTL_ESTIMATE_DAYS = int(os.getenv("EIENDOM_NO_CACHE_TTL_ESTIMATE_DAYS", "7"))
EIENDOM_NO_SIMILAR_UNITS_ENABLED = (
os.getenv("EIENDOM_NO_SIMILAR_UNITS_ENABLED", "true").lower() == "true"
)