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:
|
||||
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):
|
||||
@ -92,6 +96,11 @@ class AuctionSearchResponse(BaseModel):
|
||||
"$50 × Length × TLD × Keyword × Brand factors. "
|
||||
"See /portfolio/valuation/{domain} for detailed breakdown."
|
||||
)
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||
}
|
||||
|
||||
|
||||
class PlatformStats(BaseModel):
|
||||
@ -108,6 +117,11 @@ class ScrapeStatus(BaseModel):
|
||||
total_auctions: int
|
||||
platforms: List[str]
|
||||
next_scrape: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||
}
|
||||
|
||||
|
||||
class MarketFeedItem(BaseModel):
|
||||
@ -146,6 +160,9 @@ class MarketFeedItem(BaseModel):
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||
}
|
||||
|
||||
|
||||
class MarketFeedResponse(BaseModel):
|
||||
@ -157,6 +174,11 @@ class MarketFeedResponse(BaseModel):
|
||||
sources: List[str]
|
||||
last_updated: datetime
|
||||
filters_applied: dict = {}
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat() + "Z" if v else None
|
||||
}
|
||||
|
||||
|
||||
# ============== Helper Functions ==============
|
||||
|
||||
Reference in New Issue
Block a user