Skip to content

Commit

Permalink
Update daily_notices_metadata_update.py
Browse files Browse the repository at this point in the history
  • Loading branch information
duprijil committed Oct 6, 2023
1 parent 2733359 commit b1c5a1c
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions dags/daily_notices_metadata_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,23 @@
def daily_notices_metadata_update():
@task
def update_daily_notices_metadata_from_ted_api():
start_date = get_dag_param(key=START_DATE_PARAM_KEY)
end_date = get_dag_param(key=END_DATE_PARAM_KEY)
start_date = get_dag_param(key=START_DATE_PARAM_KEY, default_value=DEFAULT_TED_API_START_DATE)
end_date = get_dag_param(key=END_DATE_PARAM_KEY, default_value=(datetime.today() - timedelta(days=1)).strftime(
DEFAULT_TED_API_START_DATE_FORMAT))

if start_date and end_date:
start_date = datetime.strptime(start_date, "%Y-%m-%d")
end_date = datetime.strptime(end_date, "%Y-%m-%d")
else:
start_date = datetime.strptime(DEFAULT_TED_API_START_DATE, DEFAULT_TED_API_START_DATE_FORMAT)
end_date = datetime.today() - timedelta(days=1)

update_daily_notices_metadata_from_ted(start_date=start_date, end_date=end_date)
update_daily_notices_metadata_from_ted(
start_date=datetime.strptime(start_date, DEFAULT_TED_API_START_DATE_FORMAT),
end_date=datetime.strptime(end_date, DEFAULT_TED_API_START_DATE_FORMAT))

@task
def update_daily_notices_metadata_with_fetched_data_from_repo():
start_date = get_dag_param(key=START_DATE_PARAM_KEY)
end_date = get_dag_param(key=END_DATE_PARAM_KEY)
start_date = get_dag_param(key=START_DATE_PARAM_KEY, default_value=DEFAULT_TED_API_START_DATE)
end_date = get_dag_param(key=END_DATE_PARAM_KEY, default_value=(datetime.today() - timedelta(days=1)).strftime(
DEFAULT_TED_API_START_DATE_FORMAT))

if start_date and end_date:
start_date = datetime.strptime(start_date, "%Y-%m-%d")
end_date = datetime.strptime(end_date, "%Y-%m-%d")
else:
start_date = datetime.strptime(DEFAULT_TED_API_START_DATE, DEFAULT_TED_API_START_DATE_FORMAT)
end_date = datetime.today() - timedelta(days=1)
update_daily_notices_metadata_from_ted(
start_date=datetime.strptime(start_date, DEFAULT_TED_API_START_DATE_FORMAT),
end_date=datetime.strptime(end_date, DEFAULT_TED_API_START_DATE_FORMAT))

update_daily_notices_metadata_with_fetched_data(start_date=start_date, end_date=end_date)

Expand Down

0 comments on commit b1c5a1c

Please sign in to comment.