fix: Auction end_time timezone - add UTC suffix
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:
2025-12-20 21:31:30 +01:00
parent 77e3e9dc1f
commit 618eadb433

View File

@ -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):
@ -92,6 +96,11 @@ class AuctionSearchResponse(BaseModel):
"$50 × Length × TLD × Keyword × Brand factors. " "$50 × Length × TLD × Keyword × Brand factors. "
"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):
@ -108,6 +117,11 @@ class ScrapeStatus(BaseModel):
total_auctions: int total_auctions: int
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):
@ -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):
@ -157,6 +174,11 @@ class MarketFeedResponse(BaseModel):
sources: List[str] sources: List[str]
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 ==============