-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Promotions Schedule Reminder (#13)
* #4: add urgent promotional reminder * #4: add 24 hour urgency check and conditional message sending * #4: run prettier
- Loading branch information
Showing
7 changed files
with
132 additions
and
0 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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { dueTodayReminder } from "./dueTodayReminder"; | ||
export { fullItemReportReminder } from "./fullItemReportReminder"; | ||
export { urgentPromotionReminder } from "./urgentPromotionReminder"; |
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,48 @@ | ||
import { sendDiscordItemMessage } from "../discord"; | ||
import { fetchProjectV2Items } from "../github"; | ||
import { | ||
convertGithubItems, | ||
filterByLabel, | ||
filterForTwentyFourHours, | ||
filterForUrgentItems, | ||
filterOutStatus, | ||
} from "../items"; | ||
|
||
export const urgentPromotionReminder = async () => { | ||
const githubItemsResult = await fetchProjectV2Items(); | ||
if (githubItemsResult.err) { | ||
return githubItemsResult; | ||
} | ||
|
||
const items = convertGithubItems(githubItemsResult.val); | ||
const nonBacklogItems = filterOutStatus(items, "Backlog"); | ||
const urgentItems = filterForTwentyFourHours(nonBacklogItems); | ||
const itemsWithLabels = filterByLabel(urgentItems, [ | ||
"discord announcement", | ||
"social post", | ||
"scs email", | ||
]); | ||
|
||
if (itemsWithLabels.length === 0) { | ||
return null; | ||
} | ||
|
||
const message = { | ||
title: "Urgent Promotional Items Reminder 📬‼️", | ||
message: | ||
"Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 🐀🐀", | ||
sections: [ | ||
...(itemsWithLabels.length > 0 | ||
? [ | ||
{ | ||
title: "🔥 Urgent & Overdue", | ||
items: itemsWithLabels, | ||
}, | ||
] | ||
: []), | ||
], | ||
}; | ||
|
||
const discordMessageResult = await sendDiscordItemMessage(message); | ||
return discordMessageResult; | ||
}; |
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