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 5
5
import google .generativeai as genai
6
6
from datetime import datetime , timezone , timedelta
7
7
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
+
8
23
# Load environment variables from .env file
9
24
load_dotenv ()
10
25
@@ -37,7 +52,7 @@ def get_latest_buttondown_email():
37
52
# For now, we'll assume the default API call without specific filters might return
38
53
# recent ones and we'll pick the absolute latest from the results.
39
54
# 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
41
56
42
57
try :
43
58
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