Show last listing update time next to connection status in header
Add last_updated timestamp to /api/status endpoint by querying MAX(last_seen) across both listing tables. Display it in the HealthIndicator as relative time (e.g. "2h ago") with full date/time in the tooltip on hover.
This commit is contained in:
parent
7833bd3ecf
commit
2d6726dcd7
5 changed files with 55 additions and 5 deletions
|
|
@ -359,6 +359,22 @@ class ListingRepository:
|
|||
|
||||
return model_listing
|
||||
|
||||
def get_last_updated(self) -> datetime | None:
|
||||
"""Get the most recent last_seen timestamp across all listings.
|
||||
|
||||
Checks both RentListing and BuyListing tables and returns the latest.
|
||||
"""
|
||||
with Session(self.engine) as session:
|
||||
rent_max = session.execute(
|
||||
sa_select(func.max(RentListing.last_seen))
|
||||
).scalar()
|
||||
buy_max = session.execute(
|
||||
sa_select(func.max(BuyListing.last_seen))
|
||||
).scalar()
|
||||
|
||||
candidates = [t for t in (rent_max, buy_max) if t is not None]
|
||||
return max(candidates) if candidates else None
|
||||
|
||||
def get_listing_ids(
|
||||
self,
|
||||
listing_type: ListingType = ListingType.RENT,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue