Skip to content

Commit

Permalink
Merge pull request #31 from industrydive/ENGA-1120-add-new-blast-type…
Browse files Browse the repository at this point in the history
…s-to-email-metrics-reporting

ENGA-1120 Add twothirdblast type to email metrics reporting
  • Loading branch information
ddicocco authored Jul 3, 2024
2 parents e9441d0 + 5b032b0 commit 2e25e26
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ python setup.py test

Changelog
-----------------------------
v0.0.26 - added TwoThirdBlast email type
v0.0.23 - added HalfBlast email type
11 changes: 8 additions & 3 deletions dive_sailthru_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DiveEmailTypes:
Provides standard email types we use.
"""
Blast = "blast"
TwoThirdBlast = "twothirdblast"
HalfBlast = "halfblast"
ThirdBlast = "thirdblast"
QuarterBlast = "quarterblast"
Expand Down Expand Up @@ -92,6 +93,9 @@ def _infer_dive_email_type(self, campaign): # noqa: C901 - yeah it's complicat
elif "Blast" in labels or '-blast-' in name or "blast=" in name or "blast list" in list_name.lower():
if "QuarterBlast" in name or "Quarters Blast List" in list_name or "Quarter Blast List" in list_name:
return DiveEmailTypes.QuarterBlast
elif "twothirdblast" in name or "two thirds blast list" in list_name.lower() or "two third blast list" in list_name.lower():
# Must go before standard third blast
return DiveEmailTypes.TwoThirdBlast
elif "ThirdBlast" in name or "Thirds Blast List" in list_name or "Third Blast List" in list_name:
return DiveEmailTypes.ThirdBlast
elif "HalfBlast" in name or "Half Blast List" in list_name \
Expand All @@ -116,7 +120,7 @@ def _infer_dive_publication(self, campaign):
"""

# This function requires a dive_email_type, so if 'dive_email_type' is already a key
# in the campaign than use it, otherwise call it here.
# in the campaign then use it, otherwise call it here.
if 'dive_email_type' in list(campaign.keys()):
dive_email_type = campaign['dive_email_type']
else:
Expand All @@ -129,8 +133,9 @@ def _infer_dive_publication(self, campaign):
# blast list: "Utility Dive and sub pubs Blast List"
# This regex handles that as well as normal blast lists
return re.sub(r'( and sub pubs)? [Bb]last [Ll]ist$', '', list_name)
if dive_email_type in (DiveEmailTypes.HalfBlast, DiveEmailTypes.QuarterBlast, DiveEmailTypes.ThirdBlast) and "Group" in list_name:
return re.sub(r'( (Half|Thirds?|Quarters?))? Blast List - Group [A-D]$', '', list_name, flags=re.I)
if (dive_email_type in (DiveEmailTypes.HalfBlast, DiveEmailTypes.QuarterBlast, DiveEmailTypes.ThirdBlast, DiveEmailTypes.TwoThirdBlast) and
"Group" in list_name):
return re.sub(r'( (Half|(TWO )?Thirds?|Quarters?))? Blast List - Group [A-D]$', '', list_name, flags=re.I)
if dive_email_type == DiveEmailTypes.Weekender and list_name.lower().endswith("weekender"):
return re.sub(r' [Ww]eekender$', '', list_name)
if dive_email_type == DiveEmailTypes.Newsletter:
Expand Down
39 changes: 39 additions & 0 deletions dive_sailthru_client/tests/test_diveSailthruClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,45 @@ def test_infer_dive_email_type_and_brand_real_examples(self):
'expected_type': DiveEmailTypes.QuarterBlast,
'comment': 'Marketing Dive Quarter Blast with param-type blast name',
},
{
'input': {
'blast_id' : 35893250,
'email_count': 57400,
'labels' : ['Blast'],
'list' : 'Healthcare Dive TWO Third Blast List - Group B',
'mode': 'email',
'modify_time' : 'Mon, 01 Jul 2024 10:20:29 -0400',
'modify_user' : 'xxx@industrydive.com',
'name': 'client_name=CorroHealth&pt_id=a12PE000000L2bnYAC&blast=twothirdblast&site=HealthcareDive&send_date=07.09.2024',
'from_name' : 'Healthcare Dive',
'status' : 'created',
'subject' : 'Boost Hospital Revenue 7X with AI',
'suppress_list' : [],
},
'expected_publication': 'Healthcare Dive',
'expected_type': DiveEmailTypes.TwoThirdBlast,
'comment': 'Healthcare Dive Two Third Blast with param-type blast name',
},
{
'input': {
'blast_id' : 35893250,
'email_count': 57400,
'labels' : ['Blast'],
'list' : 'Healthcare Dive TWO Third Blast List - Group B',
'mode': 'email',
'modify_time' : 'Mon, 01 Jul 2024 10:20:29 -0400',
'modify_user' : 'xxx@industrydive.com',
# Intentionally editing 'name' blast param to test inference from 'list' value
'name': 'client_name=CorroHealth&pt_id=a12PE000000L2bnYAC&blast=incorrectblastparam&site=HealthcareDive&send_date=07.09.2024',
'from_name' : 'Healthcare Dive',
'status' : 'created',
'subject' : 'Boost Hospital Revenue 7X with AI',
'suppress_list' : [],
},
'expected_publication': 'Healthcare Dive',
'expected_type': DiveEmailTypes.TwoThirdBlast,
'comment': 'Healthcare Dive Two Third Blast with expected list name',
},
# You can pull the data for these tests from sailthru_tools scripts/get_campaign.py
]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="dive_sailthru_client",
version="0.0.25",
version="0.0.26",
description="Industry Dive abstraction of the Sailthru API client",
author='Industry Dive',
author_email='tech.team@industrydive.com',
Expand Down

0 comments on commit 2e25e26

Please sign in to comment.