Tell HN: Make sure to configure DKIM/SPF with Fastmail
48 pointsby whichdan24 comments
Users.all()
|> Enum.filter(&Users.is_expired?(&1, Date.utc_today()))
|> Enum.map(&generate_expiry_email/1)
|> tap(&IO.inspect(label: "Expiry Email"))
|> Enum.reject(&is_nil/1)
|> bulk_send()
The nice thing here is that we can easily log to the console, and also filter out nil expiry emails. In production code, `generate_expiry_email/1` would likely return a Result (a tuple of `{:ok, email}` or `{:error, reason}`), so we could complicate this a bit further and collect the errors to send to a logger, or to update some flag in the db. .map(g => { return { key: g.key, rows: g.rows.map(r => r[1]) }})
you can write .map(g => ({ key: g.key, rows: g.rows.map(r => r[1]) }))