Skip to content

Commit f211c35

Browse files
authored
Merge pull request #4191 from Northeastern-Electric-Racing/#4166-maintenance---slack-task-deadline-ordering
#4166 maintenance slack task deadline ordering
2 parents f62019b + 25134c3 commit f211c35

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/backend/src/services/notifications.services.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export default class NotificationsService {
4444
},
4545
dateDeleted: null
4646
},
47+
orderBy: {
48+
deadline: 'asc' // earliest (most overdue) first
49+
},
4750
include: {
4851
assignees: {
4952
include: {
@@ -78,9 +81,10 @@ export default class NotificationsService {
7881
});
7982
});
8083

81-
// send the notifications to each team for their respective tasks
84+
// send the notifications to each team for their respective tasks sorted by deadline
8285
const promises = Array.from(teamTaskMap).map(async ([slackId, tasks]) => {
8386
const messageBlock = tasks
87+
.sort((a, b) => a.deadline!.getTime() - b.deadline!.getTime())
8488
.map((task) => {
8589
// prisma call earlier allows the forced unwrap (deadline is guaranteed to be a non-null value)
8690
const todayMidnightUTC = new Date(new Date().setUTCHours(0, 0, 0, 0));
@@ -236,7 +240,6 @@ export default class NotificationsService {
236240
static async sendSponsorTaskNotifications() {
237241
const startOfToday = new Date(new Date().setUTCHours(0, 0, 0, 0));
238242
const endOfToday = startOfDayTomorrow();
239-
240243
const sponsorTasks = await prisma.sponsor_Task.findMany({
241244
where: {
242245
notifyDate: {

0 commit comments

Comments
 (0)