Bookability: show last-updated timestamp per date column
Backend adds valid_from to DateRateInfo and computes date_last_updated dict (max valid_from across categories per date). Frontend renders it as a small timestamp below the date in each column header — time only if today, date+time if older. Full ISO string in title tooltip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9e6801482f
commit
7223ae9c30
2 changed files with 40 additions and 2 deletions
|
|
@ -52,12 +52,14 @@ class DateRateInfo(BaseModel):
|
|||
tariffs: List[TariffInfo]
|
||||
tariff_count: int
|
||||
occupancy: Optional[OccupancyInfo] = None
|
||||
valid_from: Optional[str] = None
|
||||
|
||||
|
||||
class RateMatrixResponse(BaseModel):
|
||||
categories: List[CategoryInfo]
|
||||
dates: List[str]
|
||||
matrix: Dict[str, Dict[str, DateRateInfo]]
|
||||
date_last_updated: Dict[str, Optional[str]] = {}
|
||||
|
||||
|
||||
# ============================================
|
||||
|
|
@ -229,19 +231,32 @@ async def get_rate_matrix(
|
|||
|
||||
# Preserve existing occupancy data
|
||||
existing_occ = matrix[cat_id][rate_date].occupancy
|
||||
vf = row.valid_from.isoformat() if row.valid_from else None
|
||||
|
||||
matrix[cat_id][rate_date] = DateRateInfo(
|
||||
rate_gross=float(row.rate_gross) if row.rate_gross else None,
|
||||
rate_net=float(row.rate_net) if row.rate_net else None,
|
||||
tariffs=tariffs_list,
|
||||
tariff_count=tariffs_data.get('tariff_count', len(tariffs_list)),
|
||||
occupancy=existing_occ
|
||||
occupancy=existing_occ,
|
||||
valid_from=vf
|
||||
)
|
||||
|
||||
# Per-date latest update time (max valid_from across all categories for each date)
|
||||
date_last_updated: Dict[str, Optional[str]] = {}
|
||||
for date_str in dates:
|
||||
latest = None
|
||||
for cat in categories:
|
||||
vf = matrix.get(cat.category_id, {}).get(date_str, DateRateInfo(tariffs=[], tariff_count=0)).valid_from
|
||||
if vf and (latest is None or vf > latest):
|
||||
latest = vf
|
||||
date_last_updated[date_str] = latest
|
||||
|
||||
return RateMatrixResponse(
|
||||
categories=categories,
|
||||
dates=dates,
|
||||
matrix=matrix
|
||||
matrix=matrix,
|
||||
date_last_updated=date_last_updated
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue