feat(refactor): Document refactoring progress and phases in markdown

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
This commit is contained in:
Ole
2026-05-29 15:16:57 +00:00
parent 5b772b2ae5
commit 55d93894ac
18 changed files with 1457 additions and 60 deletions
+7 -2
View File
@@ -51,8 +51,8 @@ logger = logging.getLogger(__name__)
def _slim_listing(rank: int, item: dict) -> dict:
"""Collapse one full analyze_ad result into a compact listing card.
Drops: listing_description, unit_images, unit_vector, all timestamps,
full similar_units list, score dimension breakdown.
Keeps: listing_description (for AI interpretation), price_history, cache_age, score breakdown.
Drops: unit_images, unit_vector, internal eiendom_unit timestamps.
Derives: avg_comp_sqm_price from similar_units.
"""
eu = item.get("eiendom_unit") or {}
@@ -84,6 +84,8 @@ def _slim_listing(rank: int, item: dict) -> dict:
score = item.get("score") or {}
summary = item.get("summary") or {}
price_history = item.get("price_history") or []
cache_age = item.get("cache_age")
# Keep full score breakdown — 12 dimensions + nearby_transit = ~220 bytes, all signal.
# Drop nothing from scores.
@@ -113,6 +115,7 @@ def _slim_listing(rank: int, item: dict) -> dict:
"url": item.get("url"),
"title": item.get("title"),
"address": item.get("address"),
"listing_description": item.get("listing_description"),
"district": item.get("district"),
"property_type": item.get("property_type"),
"ownership_type": item.get("ownership_type"),
@@ -135,6 +138,8 @@ def _slim_listing(rank: int, item: dict) -> dict:
"categories": item.get("categories"),
"why_interesting": summary.get("why_interesting"),
"risks": summary.get("risks"),
"cache_age": cache_age,
"price_history": price_history[:5], # Last 5 price records
"eiendom": eiendom,
"similar_units": slim_comps,
}