Default ITAD_DEALS_LIMIT to 200 (API max) to maximise deal coverage
Since the ITAD API only sorts by discount or price (no time-based sort), fetching the full 200-deal window per country ensures our client-side filtering sees every available deal rather than just the top N by discount. The dedup database already prevents reposting, so the extra data is cheap. https://claude.ai/code/session_01EfPjktyrF24DBNHWsY1KBP
This commit is contained in:
@@ -31,7 +31,7 @@ EXTRA_CURRENCIES=CAD,EUR,GBP
|
|||||||
# (Falls back to shared MIN_DISCOUNT_PERCENT / MAX_PRICE if not set)
|
# (Falls back to shared MIN_DISCOUNT_PERCENT / MAX_PRICE if not set)
|
||||||
#ITAD_MIN_DISCOUNT=50
|
#ITAD_MIN_DISCOUNT=50
|
||||||
#ITAD_MAX_PRICE=20
|
#ITAD_MAX_PRICE=20
|
||||||
#ITAD_DEALS_LIMIT=100
|
#ITAD_DEALS_LIMIT=200
|
||||||
|
|
||||||
# Shared filter defaults (used when source-specific values are not set)
|
# Shared filter defaults (used when source-specific values are not set)
|
||||||
MIN_DISCOUNT_PERCENT=50
|
MIN_DISCOUNT_PERCENT=50
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Each deal source has its own filter settings. Source-specific values take priori
|
|||||||
| `CHEAPSHARK_MAX_PRICE` | CheapShark | 20 | Maximum sale price (USD) |
|
| `CHEAPSHARK_MAX_PRICE` | CheapShark | 20 | Maximum sale price (USD) |
|
||||||
| `ITAD_MIN_DISCOUNT` | ITAD | 50 | Minimum discount percentage |
|
| `ITAD_MIN_DISCOUNT` | ITAD | 50 | Minimum discount percentage |
|
||||||
| `ITAD_MAX_PRICE` | ITAD | 20 | Maximum sale price (USD, prices from other regions are converted) |
|
| `ITAD_MAX_PRICE` | ITAD | 20 | Maximum sale price (USD, prices from other regions are converted) |
|
||||||
| `ITAD_DEALS_LIMIT` | ITAD | 100 | Number of deals to fetch per country (max 200) |
|
| `ITAD_DEALS_LIMIT` | ITAD | 200 | Number of deals to fetch per country (max 200) |
|
||||||
| `MIN_DISCOUNT_PERCENT` | Shared | 50 | Fallback minimum discount when source-specific value is not set |
|
| `MIN_DISCOUNT_PERCENT` | Shared | 50 | Fallback minimum discount when source-specific value is not set |
|
||||||
| `MAX_PRICE` | Shared | 20 | Fallback maximum price when source-specific value is not set |
|
| `MAX_PRICE` | Shared | 20 | Fallback maximum price when source-specific value is not set |
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Config:
|
|||||||
self.itad_max_price = float(
|
self.itad_max_price = float(
|
||||||
os.environ.get("ITAD_MAX_PRICE", _max_price)
|
os.environ.get("ITAD_MAX_PRICE", _max_price)
|
||||||
)
|
)
|
||||||
self.itad_deals_limit = int(os.environ.get("ITAD_DEALS_LIMIT", "100"))
|
self.itad_deals_limit = int(os.environ.get("ITAD_DEALS_LIMIT", "200"))
|
||||||
|
|
||||||
# Intro message on startup
|
# Intro message on startup
|
||||||
self.send_intro_message = os.environ.get(
|
self.send_intro_message = os.environ.get(
|
||||||
|
|||||||
@@ -50,10 +50,15 @@ async def fetch_deals(
|
|||||||
countries: list[str] | None = None,
|
countries: list[str] | None = None,
|
||||||
max_price: float = 20,
|
max_price: float = 20,
|
||||||
min_discount: float = 50,
|
min_discount: float = 50,
|
||||||
limit: int = 100,
|
limit: int = 200,
|
||||||
) -> list[ITADDeal]:
|
) -> list[ITADDeal]:
|
||||||
"""Fetch current deals from IsThereAnyDeal across one or more countries.
|
"""Fetch current deals from IsThereAnyDeal across one or more countries.
|
||||||
|
|
||||||
|
Defaults to the API maximum of 200 deals per country so that client-side
|
||||||
|
filtering (discount, price, type) has the widest possible pool to work
|
||||||
|
with — this avoids missing deals that wouldn't appear in a smaller window
|
||||||
|
sorted only by discount.
|
||||||
|
|
||||||
Deals are fetched per-country, merged (first country in the list wins
|
Deals are fetched per-country, merged (first country in the list wins
|
||||||
when the same game+shop appears in multiple regions), and finally sorted
|
when the same game+shop appears in multiple regions), and finally sorted
|
||||||
by timestamp so that the newest deals appear first.
|
by timestamp so that the newest deals appear first.
|
||||||
@@ -105,7 +110,7 @@ async def _fetch_country_deals(
|
|||||||
country: str = "US",
|
country: str = "US",
|
||||||
max_price: float = 20,
|
max_price: float = 20,
|
||||||
min_discount: float = 50,
|
min_discount: float = 50,
|
||||||
limit: int = 100,
|
limit: int = 200,
|
||||||
) -> list[ITADDeal]:
|
) -> list[ITADDeal]:
|
||||||
"""Fetch deals for a single country from the ITAD ``/deals/v2`` endpoint."""
|
"""Fetch deals for a single country from the ITAD ``/deals/v2`` endpoint."""
|
||||||
params: dict = {
|
params: dict = {
|
||||||
|
|||||||
Reference in New Issue
Block a user