fixed a small database issue with price drop tracking and added doc strings

This commit is contained in:
tpv committed 2026-07-03 16:39:43 -07:00
1 parent a61dbdfaa9
commit 99d660ee52
6 files changed
+172 -4

No files matched your search

+54 -1
View File
@@ -1,3 +1,5 @@
"""Dataclass models shared across monitors and the consumer bot."""
from dataclasses import field
from datetime import datetime
@@ -6,7 +8,6 @@ from pydantic.dataclasses import dataclass
@dataclass
class ConsumerConfig:
# used claude to refactor the consumer building in the discord bot
"""Configuration for a single retailer's consumer.
Attributes:
@@ -28,6 +29,15 @@ class ConsumerConfig:
@dataclass
class PricingInfo:
"""Price fields for a product.
Attributes:
original_price: Pre-discount price.
current_price: Current listed price.
price_before_drop: Stored price prior to the last detected drop.
edu_price: Education-store price when offered.
"""
original_price: float
current_price: float
price_before_drop: float | None = None
@@ -36,6 +46,16 @@ class PricingInfo:
@dataclass
class AvailabilityInfo:
"""Availability and membership flags for a product.
Attributes:
available: Whether the product is purchasable.
condition: Product condition such as new or open box.
app_exclusive: Only purchasable through the retailer's app.
member_pick: Flagged as a member pick offer.
member_deal: Flagged as a member deal offer.
"""
available: bool | None = None
condition: str | None = None
app_exclusive: bool | None = None
@@ -45,6 +65,19 @@ class AvailabilityInfo:
@dataclass
class ProductMetadata:
"""Presentation and routing metadata for a product.
Attributes:
image_url: Product image URL.
channel_id: Resolved Discord channel id for the ping.
customization_index: Config number when priced via customization.
member_non_member_comparison: Display string comparing member and
non-member pricing.
overstock_text: Overstock label text when present.
percentage: Computed discount percentage.
affiliate_url: Affiliate link when available.
"""
image_url: str | None = None
channel_id: str | None = None
customization_index: str | None = None
@@ -56,6 +89,14 @@ class ProductMetadata:
@dataclass
class ProductTiming:
"""Lifecycle timestamps for a product.
Attributes:
discovered_date: When the product was first stored.
start_date: Offer start when the retailer provides one.
end_date: Offer end when the retailer provides one.
"""
discovered_date: datetime | None = None
start_date: datetime | None = None
end_date: datetime | None = None
@@ -63,6 +104,18 @@ class ProductTiming:
@dataclass
class Product:
"""A monitored product assembled from retailer data.
Attributes:
product_id: Retailer-specific product identifier.
title: Product title.
url: Product page URL.
pricing: Price fields.
metadata: Presentation and routing metadata.
timing: Lifecycle timestamps.
availability: Availability and membership flags.
"""
product_id: str
title: str
url: str