Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/backend/src/services/notifications.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default class NotificationsService {
},
dateDeleted: null
},
orderBy: {
deadline: 'asc' // earliest (most overdue) first
},
include: {
assignees: {
include: {
Expand Down Expand Up @@ -78,9 +81,10 @@ export default class NotificationsService {
});
});

// send the notifications to each team for their respective tasks
// send the notifications to each team for their respective tasks sorted by deadline
const promises = Array.from(teamTaskMap).map(async ([slackId, tasks]) => {
const messageBlock = tasks
.sort((a, b) => a.deadline!.getTime() - b.deadline!.getTime())
.map((task) => {
// prisma call earlier allows the forced unwrap (deadline is guaranteed to be a non-null value)
const todayMidnightUTC = new Date(new Date().setUTCHours(0, 0, 0, 0));
Expand Down Expand Up @@ -236,7 +240,6 @@ export default class NotificationsService {
static async sendSponsorTaskNotifications() {
const startOfToday = new Date(new Date().setUTCHours(0, 0, 0, 0));
const endOfToday = startOfDayTomorrow();

const sponsorTasks = await prisma.sponsor_Task.findMany({
where: {
notifyDate: {
Expand Down
Loading