1- from datetime import timedelta , date
1+ from datetime import timedelta , date , datetime
22
33from airflow .decorators import dag , task
44from airflow .models import Param
3737 tags = ['selector' , 'daily-fetch' ],
3838 params = {
3939 WILD_CARD_DAG_KEY : Param (
40+ default = f"{ date .today () - timedelta (days = 1 )} " ,
4041 type = "string" ,
4142 format = "date" ,
4243 title = "Date" ,
4344 description = """This field is required.
44- Date to fetch notices from TED. Correct format is YYYYMMDD* """
45+ Date to fetch notices from TED."""
4546 ),
4647 TRIGGER_COMPLETE_WORKFLOW_DAG_KEY : Param (
4748 default = True ,
4849 type = "boolean" ,
4950 title = "Trigger Complete Workflow" ,
5051 description = """This field is required.
51- If true, the complete workflow will be triggered, otherwise only the partial workflow will be triggered."""
52+ If true, the complete workflow will be triggered, otherwise only the partial workflow will be triggered."""
5253 )
5354 }
5455 )
@@ -61,7 +62,11 @@ def fetch_notices_by_date():
6162 ))
6263 )
6364 def fetch_by_date_notice_from_ted ():
64- notice_ids = notice_fetcher_by_date_pipeline (date_wild_card = get_dag_param (key = WILD_CARD_DAG_KEY ))
65+ default_date = (datetime .now () - timedelta (days = 1 )).strftime ("%Y-%m-%d" )
66+ selected_date = datetime .strptime (get_dag_param (key = WILD_CARD_DAG_KEY ,
67+ default_value = default_date ), "%Y-%m-%d" )
68+ date_wild_card = datetime .strftime (selected_date , "%Y%m%d*" )
69+ notice_ids = notice_fetcher_by_date_pipeline (date_wild_card = date_wild_card )
6570 if not notice_ids :
6671 log_error ("No notices has been fetched!" )
6772 else :
@@ -83,10 +88,10 @@ def validate_fetched_notices():
8388 from ted_sws .supra_notice_manager .services .supra_notice_validator import validate_and_update_daily_supra_notice
8489 from datetime import datetime
8590 from pymongo import MongoClient
86-
91+ default_date = ( datetime . now () - timedelta ( days = 1 )). strftime ( "%Y-%m-%d" )
8792 publication_date = datetime .strptime (get_dag_param (key = WILD_CARD_DAG_KEY ,
88- default_value = ( datetime . now () - timedelta ( days = 1 )). strftime (
89- "%Y%m%d*" )) , "%Y%m%d* " )
93+ default_value = default_date
94+ ) , "%Y-%m-%d " )
9095 mongodb_client = MongoClient (config .MONGO_DB_AUTH_URL )
9196 validate_and_update_daily_supra_notice (ted_publication_date = publication_date , mongodb_client = mongodb_client )
9297
0 commit comments