File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 55import google .generativeai as genai
66from datetime import datetime , timezone , timedelta
77
8+ from dateutil .parser import parse
9+ from datetime import datetime , timedelta , timezone
10+
11+ # Get today's date
12+ today = datetime .today ()
13+
14+ # Calculate the date 7 days ago
15+ seven_days_ago = today - timedelta (days = 7 )
16+
17+ # Format the date in YYYY-MM-DD format
18+ formatted_date = seven_days_ago .strftime ('%Y-%m-%d' )
19+
20+ # The variable to store the date
21+ date_seven_days_ago = formatted_date
22+
823# Load environment variables from .env file
924load_dotenv ()
1025
@@ -37,7 +52,7 @@ def get_latest_buttondown_email():
3752 # For now, we'll assume the default API call without specific filters might return
3853 # recent ones and we'll pick the absolute latest from the results.
3954 # A more robust approach might involve `?ordering=-publish_date&limit=1` if the API supports it.
40- FILTERS = f"page_size =1&email_type=public" # Attempt to get just one, the most recent
55+ FILTERS = f"publish_date__start= { date_seven_days_ago } &page =1&email_type=public" # Attempt to get just one, the most recent
4156
4257 try :
4358 response = requests .request ("GET" , f"{ BUTTONDOWN_BASE_URL } /v1{ BUTTONDOWN_ENDPOINT } ?{ FILTERS } " , headers = headers )
You can’t perform that action at this time.
0 commit comments