Skip to content

Commit 8ef7d6c

Browse files
committed
Fixed SAM opportunities to deal with no post dates
1 parent 8ba683c commit 8ef7d6c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/procurement_tools/cli/main.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from procurement_tools import FAR, USASpending, SAM, SBIR
44
from procurement_tools.models.opportunities import OpportunitiesRequestParams
55
import typer
6+
from typing import Optional
67
from typing_extensions import Annotated
78

89
app = typer.Typer()
@@ -34,21 +35,25 @@ def entity(uei: str):
3435
def opportunities(
3536
*,
3637
q: str = "",
37-
postedFrom: str = datetime.now().strftime("%Y-%m-%d"),
38-
postedTo: str = datetime.now().strftime("%Y-%m-%d"),
38+
postedFrom: Optional[
39+
str
40+
] = None, # (datetime.now() - timedelta(days=364)).strftime("%Y-%m-%d"),
41+
postedTo: Optional[str] = None, # datetime.now().strftime("%Y-%m-%d"),
3942
active: str = "true",
4043
mode: str = "ALL",
4144
):
4245
"""Get SAM opportunities' JSON data"""
43-
res = SAM.get_opportunities(
44-
{
45-
"q": q,
46-
"modified_date.from": postedFrom + "-06:00",
47-
"modified_date.to": postedTo + "-06:00",
48-
"active": active,
49-
"mode": mode,
50-
}
51-
)
46+
params = {
47+
"q": q,
48+
"active": active,
49+
"mode": mode,
50+
}
51+
if postedFrom:
52+
params["modified_date.from"] = (postedFrom + "-06:00",)
53+
if postedTo:
54+
params["modified_date.to"] = (postedTo + "-06:00",)
55+
56+
res = SAM.get_opportunities(params)
5257
print(json.dumps(res))
5358

5459

0 commit comments

Comments
 (0)