-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Notification Email Data (#1693)
* Adding type for email digest data * Extract deliverNotifications into shared function between cron and request * Remove extraneous comments * Moving nextDigestAt from individual activeTopicSubscriptions to the User record. We send digests at a user level, so it no longer makes sense to track digests individually by topic * Handling nextDigestAt edge case to prevent skipping notification days due to variance in digest runtimes * Modify deliverEmailNotifications to work off of a list of users that have pending digests, rather than by scanning the digest topics directly * Digesting user notifications into usable data for email notifications * Do not send email if there are no new notifications * fix: Removing unnecessary Timestamp import to prevent integration test error * change: Making the bills sort in the email digest computation more legible by grouping the counts by bill * Update cron job to only run on days we send out notifications
- Loading branch information
Showing
15 changed files
with
294 additions
and
432 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Frequency } from "../auth/types" | ||
|
||
export type BillDigest = { | ||
billId: string | ||
billName: string | ||
billCourt: string | ||
endorseCount: number | ||
neutralCount: number | ||
opposeCount: number | ||
} | ||
export type Position = "endorse" | "neutral" | "oppose" | ||
export type BillResult = { | ||
billId: string | ||
court: string | ||
position: Position | ||
} | ||
export type UserDigest = { | ||
userId: string | ||
userName: string | ||
bills: BillResult[] | ||
newTestimonyCount: number // displayed bills are capped at 6 | ||
} | ||
export type NotificationEmailDigest = { | ||
notificationFrequency: Frequency | ||
startDate: Date | ||
endDate: Date | ||
bills: BillDigest[] // cap of 4 | ||
numBillsWithNewTestimony: number | ||
users: UserDigest[] // cap of 4 | ||
numUsersWithNewTestimony: number | ||
} |
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
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
Oops, something went wrong.