Skip to content

Commit 59296ed

Browse files
committed
Update structure of tasks
1 parent 9b3e366 commit 59296ed

15 files changed

Lines changed: 243 additions & 221 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "npx tsc",
88
"test": "npx jest --testPathIgnorePatterns=dist/",
99
"job": "node dist/src/jobs/index.js",
10-
"prod": "npx ts-node -r tsconfig-paths/register src/jobs/index.ts",
10+
"task": "npx ts-node -r tsconfig-paths/register src/tasks.ts",
1111
"dev": "nodemon src/jobs/dailyTaskReminder.ts",
1212
"check": "prettier --check '**/*.{css,scss,html,js,md,ts,tsx}'",
1313
"format": "prettier --write '**/*.{css,scss,html,js,md,ts,tsx}'"

src/constants.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export const EMOJIS = [
2+
"🎉",
3+
"🚀",
4+
"📅",
5+
"🔔",
6+
"📌",
7+
"📍",
8+
"✨",
9+
"🌟",
10+
"💡",
11+
"🔍",
12+
"📈",
13+
"🏆",
14+
"🛠",
15+
"🖌",
16+
"📝",
17+
"🗂",
18+
"📊",
19+
"📚",
20+
"🔖",
21+
"🔗",
22+
"📎",
23+
"💼",
24+
"🗓",
25+
"🚧",
26+
"🎯",
27+
"🧭",
28+
"🎈",
29+
"🎠",
30+
"🏁",
31+
"✅",
32+
"📜",
33+
"📖",
34+
"🔑",
35+
"🎁",
36+
"🔓",
37+
"🔧",
38+
"🔨",
39+
"🛏",
40+
"🧹",
41+
"🔥",
42+
"🕯",
43+
"🛋",
44+
"🪑",
45+
"🚪",
46+
"🪟",
47+
"🧸",
48+
"🖼",
49+
"🛒",
50+
"🎊",
51+
"📯",
52+
"💖",
53+
"💫",
54+
"🌈",
55+
"🎶",
56+
"💻",
57+
"🖥",
58+
"🖨",
59+
"🖱",
60+
"🕹",
61+
"🗜",
62+
];

src/jobs/dailyTaskReminder.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/jobs/promotionReminder.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/reminders/dueTodayReminder.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.

src/reminders/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/reminders/fullItemReportReminder.ts renamed to src/reminders/messages/completeTaskReportMessage.ts

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
import { sendDiscordItemMessage } from "../infrastructure/discord";
2-
import { fetchProjectV2Items } from "../infrastructure/github";
3-
import {
4-
filterForUnassigned,
5-
filterForUrgentItems,
6-
filterOutStatus,
7-
filterUpcomingItems,
8-
} from "../items";
1+
import { DiscordItemMessage } from "@infrastructure/discord";
2+
import { Item } from "@src/items";
93

10-
export const fullItemReportReminder = async () => {
11-
const githubItemsResult = await fetchProjectV2Items();
12-
if (githubItemsResult.err) {
13-
return githubItemsResult;
14-
}
4+
interface Props {
5+
urgentItems: Item[];
6+
unassignedItems: Item[];
7+
upcomingItems: Item[];
8+
}
159

16-
const nonBacklogItems = filterOutStatus(githubItemsResult.val, "Backlog");
17-
const unassignedItems = filterForUnassigned(nonBacklogItems);
18-
const upcomingItems = filterUpcomingItems(nonBacklogItems);
19-
const urgentItems = filterForUrgentItems(nonBacklogItems);
20-
21-
const message = {
10+
export const completeTaskReportMessage = ({
11+
urgentItems,
12+
unassignedItems,
13+
upcomingItems,
14+
}: Props): DiscordItemMessage => {
15+
return {
2216
title: "Biweekly Tasks Reminder ☀️🌱",
2317
message:
2418
urgentItems.length === 0 &&
@@ -56,7 +50,4 @@ export const fullItemReportReminder = async () => {
5650
: []),
5751
],
5852
};
59-
60-
const discordMessageResult = await sendDiscordItemMessage(message);
61-
return discordMessageResult;
6253
};

src/reminders/messages/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { completeTaskReportMessage } from "./completeTaskReportMessage";
2+
export { simpleTaskReportMessage } from "./simpleTaskReportMessage";
3+
export { urgentPromotionMessage } from "./urgentPromotionMessage";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Item } from "@src/items";
2+
import { DiscordItemMessage } from "@infrastructure/discord";
3+
import { EMOJIS } from "@src/constants";
4+
5+
interface Props {
6+
urgentItems: Item[];
7+
unassignedItems: Item[];
8+
}
9+
10+
export const simpleTaskReportMessage = ({
11+
urgentItems,
12+
unassignedItems,
13+
}: Props): DiscordItemMessage => {
14+
const randomEmoji = EMOJIS[Math.floor(Math.random() * EMOJIS.length)];
15+
16+
return {
17+
title: `Daily Task Reminder ${randomEmoji}`,
18+
message:
19+
urgentItems.length === 0 && unassignedItems.length === 0
20+
? "Nothing urgent or unassigned today! 🐀🥂"
21+
: "Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 👀",
22+
sections: [
23+
...(urgentItems.length > 0
24+
? [
25+
{
26+
title: "🔥 Urgent & Overdue",
27+
items: urgentItems,
28+
includeLinks: true,
29+
},
30+
]
31+
: []),
32+
...(unassignedItems.length > 0
33+
? [
34+
{
35+
title: "📥 Unassigned Items",
36+
items: unassignedItems,
37+
includeLinks: false,
38+
},
39+
]
40+
: []),
41+
],
42+
};
43+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { DiscordItemMessage } from "@infrastructure/discord";
2+
import { Item } from "@src/items";
3+
4+
interface Props {
5+
promotionItems: Item[];
6+
}
7+
8+
export const urgentPromotionMessage = ({
9+
promotionItems,
10+
}: Props): DiscordItemMessage => {
11+
return {
12+
title: "Urgent Promotional Items Reminder 📬‼️",
13+
message:
14+
"Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 🦆",
15+
sections: [
16+
...(promotionItems.length > 0
17+
? [
18+
{
19+
title: "🔔 Urgent Promotion Items",
20+
items: promotionItems,
21+
includeLinks: true,
22+
},
23+
]
24+
: []),
25+
],
26+
};
27+
};

0 commit comments

Comments
 (0)