fix: Auction end_time timezone - add UTC suffix
Some checks failed
Deploy Pounce / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy Pounce / build-and-deploy (push) Has been cancelled
The frontend was calculating wrong time remaining because end_time was sent without timezone suffix (Z). JavaScript's new Date() interprets "2025-12-20T20:49:20" as local time, but the server stores it as UTC. Fix: Add json_encoders to Pydantic models that append "Z" to all datetime fields, marking them as UTC. Affected models: - AuctionListing - AuctionSearchResponse - MarketFeedItem - MarketFeedResponse - ScrapeStatus
This commit is contained in:
@ -78,6 +78,10 @@ class AuctionListing(BaseModel):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
# Serialize datetimes as ISO format with UTC timezone suffix
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AuctionSearchResponse(BaseModel):
|
class AuctionSearchResponse(BaseModel):
|
||||||
@ -93,6 +97,11 @@ class AuctionSearchResponse(BaseModel):
|
|||||||
"See /portfolio/valuation/{domain} for detailed breakdown."
|
"See /portfolio/valuation/{domain} for detailed breakdown."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class PlatformStats(BaseModel):
|
class PlatformStats(BaseModel):
|
||||||
"""Statistics for an auction platform."""
|
"""Statistics for an auction platform."""
|
||||||
@ -109,6 +118,11 @@ class ScrapeStatus(BaseModel):
|
|||||||
platforms: List[str]
|
platforms: List[str]
|
||||||
next_scrape: Optional[datetime]
|
next_scrape: Optional[datetime]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class MarketFeedItem(BaseModel):
|
class MarketFeedItem(BaseModel):
|
||||||
"""Unified market feed item - combines auctions and Pounce Direct listings."""
|
"""Unified market feed item - combines auctions and Pounce Direct listings."""
|
||||||
@ -146,6 +160,9 @@ class MarketFeedItem(BaseModel):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class MarketFeedResponse(BaseModel):
|
class MarketFeedResponse(BaseModel):
|
||||||
@ -158,6 +175,11 @@ class MarketFeedResponse(BaseModel):
|
|||||||
last_updated: datetime
|
last_updated: datetime
|
||||||
filters_applied: dict = {}
|
filters_applied: dict = {}
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ============== Helper Functions ==============
|
# ============== Helper Functions ==============
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user