Skip to content

Commit

Permalink
Add env in data refresh notifications (#5115)
Browse files Browse the repository at this point in the history
  • Loading branch information
stacimc authored Oct 31, 2024
1 parent 01dfe6f commit b484609
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions catalog/dags/data_refresh/dag_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def create_data_refresh_dag(
"after": after_record_count,
"media_type": data_refresh_config.media_type,
"dag_id": data_refresh_config.dag_id,
"env": target_environment,
},
)

Expand Down
10 changes: 7 additions & 3 deletions catalog/dags/data_refresh/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def report_status(media_type: str, message: str, dag_id: str):
return message


def report_record_difference(before: dict, after: dict, media_type: str, dag_id: str):
def report_record_difference(
before: dict, after: dict, media_type: str, dag_id: str, env: str
):
all_keys = before.keys() | after.keys()
total_before = sum(before.values())
total_after = sum(after.values())
Expand All @@ -37,7 +39,7 @@ def report_record_difference(before: dict, after: dict, media_type: str, dag_id:

message = dedent(
f"""
Data refresh for {media_type} complete! :tada:
{env.capitalize()} data refresh for {media_type} complete! :tada:
_Note: All values are retrieved from elasticsearch_
*Record count difference for `{media_type}`*: {total_before:,}{total_after:,}
*Change*: {count_diff:+,} ({percent_diff:+}% Δ)
Expand All @@ -46,6 +48,8 @@ def report_record_difference(before: dict, after: dict, media_type: str, dag_id:
)
message += breakdown_message
slack.send_message(
text=message, dag_id=dag_id, username="Data refresh record difference"
text=message,
dag_id=dag_id,
username=f"{env.capitalize()} data refresh record difference",
)
return message

0 comments on commit b484609

Please sign in to comment.