55d93894ac
feat(scripts): Add backfill script for content_hash in cache tables feat(scripts): Create recompute script for analysis_cache population test(tests): Implement comprehensive tests for analysis module functions fix(tests): Update CLI tests to assert errors on stderr instead of stdout fix(tests): Adjust MCP integration tests to pass context parameter correctly fix(tests): Modify service tests to return hash on save functions for consistency
49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
"""Configuration and environment variables."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Cache and database
|
|
FINN_CACHE_PATH = os.getenv("FINN_CACHE_PATH", str(Path("data/finn.sqlite")))
|
|
|
|
# FINN API settings
|
|
FINN_MAX_SEARCH_PAGES = int(os.getenv("FINN_MAX_SEARCH_PAGES", "3"))
|
|
FINN_DETAIL_LIMIT = int(os.getenv("FINN_DETAIL_LIMIT", "20"))
|
|
FINN_REQUEST_DELAY_SECONDS = float(os.getenv("FINN_REQUEST_DELAY_SECONDS", "2"))
|
|
FINN_USER_AGENT = os.getenv("FINN_USER_AGENT", "personal-finn-eiendom-analyzer/0.1")
|
|
|
|
# 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")
|
|
)
|
|
# 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)
|
|
FINN_CACHE_TTL_SEARCH_MINUTES = int(os.getenv("FINN_CACHE_TTL_SEARCH_MINUTES", "360"))
|
|
|
|
# Eiendom.no API settings
|
|
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_SIMILAR_UNITS_ENABLED = (
|
|
os.getenv("EIENDOM_NO_SIMILAR_UNITS_ENABLED", "true").lower() == "true"
|
|
)
|
|
EIENDOM_NO_SIMILAR_UNITS_DEFAULT_STATUS = os.getenv(
|
|
"EIENDOM_NO_SIMILAR_UNITS_DEFAULT_STATUS", "RECENTLY_SOLD"
|
|
)
|
|
# Similar units (comps) are immutable; very long TTL (only new entries appear over time)
|
|
EIENDOM_NO_CACHE_TTL_SIMILAR_UNITS_DAYS = int(
|
|
os.getenv("EIENDOM_NO_CACHE_TTL_SIMILAR_UNITS_DAYS", "60")
|
|
)
|
|
|
|
# Logging
|
|
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
|