Market View: honest staleness per cell after partial scrapes
- matrix response gains last_scraped per date (max scraped_at across all hotels), so column headers show the newest scrape touching the date even when the visible hotels were on a failed page - cells >1h older than the column's latest scrape render italic with * - every cell tooltip now includes the datestamp the price was scraped Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
218b2f45f6
commit
bf9425ee7e
2 changed files with 38 additions and 6 deletions
|
|
@ -520,6 +520,23 @@ async def get_competitor_matrix(
|
|||
'scraped_at': row.scraped_at.isoformat() if row.scraped_at else None,
|
||||
}
|
||||
|
||||
# Most recent scrape touching each date, across ALL hotels — a partial
|
||||
# scrape may refresh the date without touching the displayed hotels, so
|
||||
# per-cell scraped_at can lag behind this column-level timestamp
|
||||
last_scraped_result = await db.execute(
|
||||
text("""
|
||||
SELECT rate_date, MAX(scraped_at) AS last_scraped
|
||||
FROM booking_com_rates
|
||||
WHERE rate_date >= :from_date AND rate_date <= :to_date
|
||||
GROUP BY rate_date
|
||||
"""),
|
||||
{'from_date': start, 'to_date': end}
|
||||
)
|
||||
last_scraped = {
|
||||
row.rate_date.isoformat(): row.last_scraped.isoformat() if row.last_scraped else None
|
||||
for row in last_scraped_result.fetchall()
|
||||
}
|
||||
|
||||
# Build date list
|
||||
dates = []
|
||||
current = start
|
||||
|
|
@ -532,7 +549,8 @@ async def get_competitor_matrix(
|
|||
'to_date': end.isoformat(),
|
||||
'dates': dates,
|
||||
'hotels': hotels,
|
||||
'rates': rates_by_hotel
|
||||
'rates': rates_by_hotel,
|
||||
'last_scraped': last_scraped
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue