Skip to content

Commit

Permalink
Fix #778: switch newsletters timestamps columns to date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Jul 25, 2023
1 parent d44854f commit 321aadf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
25 changes: 14 additions & 11 deletions ctms/acoustic_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,20 @@ def _newsletter_converter(self, acoustic_main_table, contact, newsletters_mappin
acoustic_main_table[sub_flag] = "0"

for newsletter in contact_newsletters:
newsletter_row = {
"email_id": contact_email_id,
"newsletter_name": newsletter.name,
"newsletter_source": newsletter.source and str(newsletter.source),
"create_timestamp": newsletter.create_timestamp.date().isoformat(),
"update_timestamp": newsletter.update_timestamp.date().isoformat(),
"newsletter_format": newsletter.format,
"newsletter_lang": newsletter.lang,
"subscribed": transform_field_for_acoustic(newsletter.subscribed),
"newsletter_unsub_reason": newsletter.unsub_reason,
}
newsletter_row = {}
for column, field in (
("email_id", "email_id"),
("newsletter_name", "name"),
("newsletter_source", "source"),
("newsletter_format", "format"),
("newsletter_lang", "lang"),
("subscribed", "subscribed"),
("newsletter_unsub_reason", "unsub_reason"),
("create_timestamp", "create_timestamp"),
("update_timestamp", "update_timestamp"),
):
value = getattr(newsletter, field)
newsletter_row[column] = transform_field_for_acoustic(value)
newsletter_rows.append(newsletter_row)

if newsletter.name in newsletters_mapping:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_acoustic_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def test_ctms_to_acoustic_newsletter_timestamps(
)

app_dev_row = [r for r in newsletters_rows if r["newsletter_name"] == "app-dev"][0]
assert app_dev_row["create_timestamp"] == "1982-05-08"
assert app_dev_row["update_timestamp"] == "2023-06-19"
assert app_dev_row["create_timestamp"] == "05/08/1982 13:20:00"
assert app_dev_row["update_timestamp"] == "06/19/2023 12:17:00"


def test_ctms_to_acoustic_waitlists_minimal(
Expand Down

0 comments on commit 321aadf

Please sign in to comment.