Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #778: switch newsletters timestamps columns to date and time #779

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions ctms/acoustic_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def _newsletter_converter(self, acoustic_main_table, contact, newsletters_mappin
# create the RT rows for the newsletter table in acoustic
newsletter_rows = []
contact_newsletters: List[NewsletterSchema] = contact.newsletters
contact_email_id = str(contact.email.email_id)
skipped = []

# populate with all the sub_flags set to false
Expand All @@ -298,17 +297,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"
leplatrem marked this conversation as resolved.
Show resolved Hide resolved
assert app_dev_row["update_timestamp"] == "06/19/2023 12:17:00"


def test_ctms_to_acoustic_waitlists_minimal(
Expand Down