latest_prices: include_expired passthrough for historical data (#2)
This commit was merged in pull request #2.
This commit is contained in:
+12
-2
@@ -176,13 +176,22 @@ def latest_prices(
|
||||
Field(description="Search radius in miles around the location (default 50). "
|
||||
"Ignored unless a ZIP or lat/lng is given."),
|
||||
] = None,
|
||||
include_expired: Annotated[
|
||||
bool,
|
||||
Field(description="Include past/expired delivery months. Default off — only "
|
||||
"the current and future months are shown. Set true only when "
|
||||
"the farmer explicitly asks for historical/past delivery data."),
|
||||
] = False,
|
||||
) -> str:
|
||||
"""Snapshot of the latest scraped bid per (source, commodity, delivery).
|
||||
|
||||
Every filter is optional and AND'd together — pivot by elevator, crop,
|
||||
delivery, or kind in any combination. Pass a `zip` (or `lat`+`lng`) with
|
||||
optional `radius_miles` to keep only elevators near the farmer, sorted
|
||||
nearest-first with the distance shown."""
|
||||
nearest-first with the distance shown.
|
||||
|
||||
By default this shows current + future delivery months only; expired
|
||||
months are rolled off. Set `include_expired=true` for a historical view."""
|
||||
cm = commodity.strip().lower() if commodity else None
|
||||
with track("latest_prices", commodity=cm, source=source, delivery=delivery, kind=kind,
|
||||
zip=zip or "", radius=radius_miles or 0):
|
||||
@@ -190,7 +199,8 @@ def latest_prices(
|
||||
if err:
|
||||
return err
|
||||
payload = client.latest(commodity=cm, source=source, delivery=delivery, kind=kind,
|
||||
zip=zip, lat=lat, lng=lng, radius_miles=radius_miles)
|
||||
zip=zip, lat=lat, lng=lng, radius_miles=radius_miles,
|
||||
include_expired=include_expired)
|
||||
return fmt.fmt_latest(payload)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user