Skip to content

Instantly share code, notes, and snippets.

@jaredh159
Created February 3, 2025 17:20
Show Gist options
  • Save jaredh159/19da71a427ce2b890458f0694ce624c8 to your computer and use it in GitHub Desktop.
Save jaredh159/19da71a427ce2b890458f0694ce624c8 to your computer and use it in GitHub Desktop.
send-new-release-marketing-email.md
Task {
let postmark = get(dependency: \.postmark)
let db = get(dependency: \.db)
let admins = try await Admin.query()
.where(.not(.equals(
.subscriptionStatus,
.enum(Admin.SubscriptionStatus.unpaid)
)))
.where(.not(.equals(
.subscriptionStatus,
.enum(Admin.SubscriptionStatus.pendingEmailVerification)
)))
.where(.not(.equals(
.subscriptionStatus,
.enum(Admin.SubscriptionStatus.pendingAccountDeletion)
)))
.orderBy(.email, .asc)
.all(in: db)
do {
for chunk in admins.chunks(ofCount: 40) {
// print(chunk.count, chunk.first?.email.rawValue)
let emails = chunk.map(\.email.rawValue)
try await postmark.send(template: .v2_7_0_Announce(
to: emails,
model: .init(),
dryRun: false
))
}
} catch {
print(String(reflecting: error))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment