Skip to content

Commit 6377f54

Browse files
committed
Filter out empty sections and emails
1 parent 73ce699 commit 6377f54

File tree

1 file changed

+12
-8
lines changed
  • datapackage_pipelines_budgetkey/pipelines/budgetkey/emails

1 file changed

+12
-8
lines changed

datapackage_pipelines_budgetkey/pipelines/budgetkey/emails/send_emails.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ def process_row(row, *_):
5555
term=props['term'],
5656
query_url=query_url(props['term'], filters)
5757
))
58-
sections.append(section)
59-
ret = dict(
60-
sections=sections,
61-
email=row['email']
62-
)
63-
logging.info('DATAS: %r', ret)
64-
result = requests.post('http://budgetkey-emails:8000/', json=ret).json()
65-
logging.info('RESULT: %r', result)
58+
if len(terms) > 0:
59+
sections.append(section)
60+
if len(sections) > 0:
61+
ret = dict(
62+
sections=sections,
63+
email=row['email']
64+
)
65+
logging.info('DATAS: %r', ret)
66+
result = requests.post('http://budgetkey-emails:8000/', json=ret).json()
67+
logging.info('RESULT: %r', result)
68+
else:
69+
logging.info('SKIPPING %s as has no relevant subscriptions', row['email'])
6670

6771

6872
if __name__ == '__main__':

0 commit comments

Comments
 (0)