Skip to content

Commit

Permalink
Update promotion reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyouMB committed Jun 29, 2024
1 parent aff7a6d commit a8b2a08
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/items/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,13 @@ export const filterForUrgentItems = (items: Item[]) => {
//due the next day
export const filterForTwentyFourHours = (items: Item[]) => {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setDate(tomorrow.getDate() + 2);

return items.filter((item) => {
if (!item.dueDate) {
return false;
}
return (
item.dueDate <= tomorrow &&
item.status !== "Done" &&
item.assignedUsers.length !== 0
);
return item.dueDate <= tomorrow && item.status !== "Done";
});
};

Expand Down
5 changes: 5 additions & 0 deletions src/jobs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command } from "commander";
import { dailyTaskReminder } from "./dailyTaskReminder";
import { promotionReminder } from "./promotionReminder";

const program = new Command();

Expand All @@ -12,6 +13,10 @@ program
dailyTaskReminder();
break;
}
case "promotionReminder": {
promotionReminder();
break;
}
default: {
console.log("Please enter a valid job name");
break;
Expand Down
5 changes: 5 additions & 0 deletions src/jobs/promotionReminder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { urgentPromotionReminder } from "../reminders";

export const promotionReminder = async () => {
urgentPromotionReminder();
};
8 changes: 5 additions & 3 deletions src/reminders/urgentPromotionReminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
convertGithubItems,
filterByLabel,
filterForTwentyFourHours,
filterForUrgentItems,
filterOutStatus,
} from "../items";

Expand All @@ -24,25 +23,28 @@ export const urgentPromotionReminder = async () => {
]);

if (itemsWithLabels.length === 0) {
console.log("No urgent promotion items");
return null;
}

const message = {
title: "Urgent Promotional Items Reminder 📬‼️",
message:
"Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 🐀🐀",
"Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 🦆",
sections: [
...(itemsWithLabels.length > 0
? [
{
title: "🔥 Urgent & Overdue",
title: "🔔 Urgent Promotion Items",
items: itemsWithLabels,
includeLinks: true,
},
]
: []),
],
};

console.log("Sending promotion reminder");
const discordMessageResult = await sendDiscordItemMessage(message);
return discordMessageResult;
};

0 comments on commit a8b2a08

Please sign in to comment.