Created
February 3, 2025 17:20
-
-
Save jaredh159/19da71a427ce2b890458f0694ce624c8 to your computer and use it in GitHub Desktop.
send-new-release-marketing-email.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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