Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3849f66
added a isWithinBuffer method
glickgNU Sep 17, 2026
6942caf
Merge branch 'develop' of https://github.com/Northeastern-Electric-Ra…
glickgNU Sep 17, 2026
0ffc5c2
removed unnecessary log
glickgNU Sep 17, 2026
e6cfe42
prettier + tests
glickgNU Sep 17, 2026
4bb0ef4
tests
glickgNU Sep 17, 2026
48a4cf2
updated isWithinBuffer
glickgNU Sep 17, 2026
b997536
removed file changes that shouldn't be changed
glickgNU Sep 17, 2026
3067859
updated tsconfig
glickgNU Sep 17, 2026
2cd1538
change tsconfig again
glickgNU Sep 17, 2026
26a1565
updated to deal with unneeded file changes + moved shared/utils.ts ->…
glickgNU Sep 21, 2026
f67ef1a
added eol
glickgNU Sep 21, 2026
d8ee46a
eol for yarn.lock
glickgNU Sep 21, 2026
778dd4a
updated test location
glickgNU Sep 21, 2026
9dac2eb
change paths for isWithinBuffer
glickgNU Sep 22, 2026
3398c5a
changes to deal with errors
glickgNU Sep 23, 2026
66ef547
updated with some issues fixed
glickgNU Sep 23, 2026
f8d5f9a
changed location for testing
glickgNU Sep 23, 2026
9bb8dd7
current state, unfinished but want to just commit
glickgNU Sep 24, 2026
c08e1d4
pushed with changes
glickgNU Oct 8, 2026
b64ec35
added changed to deal with linter
glickgNU Oct 8, 2026
7527c65
implemented some of steph's suggestions
glickgNU Oct 14, 2026
80a0e1a
added more suggestions
glickgNU Oct 15, 2026
cf10e73
removed unused import
glickgNU Oct 15, 2026
c410a78
small polishes
glickgNU Oct 15, 2026
175747b
fixed destructuring error
glickgNU Oct 15, 2026
7b6bace
Merge branch 'feature/change-request-buffer' into #4411-activation-sl…
Steph375 Oct 16, 2026
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
12 changes: 11 additions & 1 deletion src/backend/src/services/change-requests.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { throwIfUncheckedDescriptionBullets } from '../utils/description-bullets
import { buildChangeDetail } from '../utils/changes.utils.js';
import {
addSlackThreadsToChangeRequest,
sendActivationStartDateChangedNotification,
sendAndGetSlackCRNotifications,
sendSlackCRStatusToThread,
sendSlackRequestedReviewNotification,
Expand Down Expand Up @@ -640,7 +641,16 @@ export default class ChangeRequestsService {
new Date(startDate),
organization.activationBufferDays
);
if (inBuffer) {
if (!inBuffer) {
await sendActivationStartDateChangedNotification(
teams,
leadId,
managerId,
new Date(startDate),
createdCR.wbsElement?.workPackage?.startDate,
wbsPipe(createdCR.wbsElement),
createdCR.wbsElement?.name
);
}
}

Expand Down
60 changes: 58 additions & 2 deletions src/backend/src/utils/slack.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Team as SharedTeam,
TeamJoinRequest
} from 'shared';
import { Account_Code, Organization, Reimbursement_Product_Other_Reason, Sponsor_Task } from '@prisma/client';
import { Account_Code, Organization, Reimbursement_Product_Other_Reason, Sponsor_Task, Team_Type } from '@prisma/client';
import {
editMessage,
getChannelName,
Expand All @@ -23,7 +23,7 @@ import {
sendEphemeralMessage,
sendMessage
} from '../integrations/slack.js';
import { getUserSlackId, getUserSlackMentionOrName } from './users.utils.js';
import { getUserSlackId, getUserSlackMentionOrName, getUsersWithSettings } from './users.utils.js';
import prisma from '../prisma/prisma.js';
import { HttpException } from './errors.utils.js';
import { Change_Request, Team, WBS_Element } from '@prisma/client';
Expand Down Expand Up @@ -984,3 +984,59 @@ export const notifySponsorTaskAssignee = async (
const linkButtonText = `View Tasks for ${sponsor}`;
await sendMessage(assignee.userSettings?.slackId, msg, link, linkButtonText);
};

/**
* Sends to team channels as well as leads and manager about

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only sends to the team channels pinging the lead and manager

* a work package that is scheduled to start at a later date than anticipated
*
* @param teams The teams to notify
* @param leadId The work package's lead
* @param managerId The work package's manager
* @param startDate The planned starting date for the work package
* @param activationDate The actual starting date for the work package
* @param bufferDays The threshold that triggers this message

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a param

* @param wbsString The wbs number as a string type
* @param name Name of the work package
*/
Comment thread
Steph375 marked this conversation as resolved.
export const sendActivationStartDateChangedNotification = async (
teams: (Team & { teamType: Team_Type | null })[] | undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not just an array of teams?

leadId: string = '',
managerId: string = '',
startDate: Date,
activationDate: Date,
wbsString: string,
name: string
) => {
const leadIdPing = (await pingBasedOnId(leadId)) || '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather use getUserSlackMentionOrName

const managerIdPing = (await pingBasedOnId(managerId)) || '';

const activationDateString = activationDate.toDateString();
const startDateString = startDate.toDateString();

Comment thread
Steph375 marked this conversation as resolved.
const message =
leadIdPing +
' ' +
managerIdPing +
' The start date for ' +
name +
' has been changed from ' +
startDateString +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure the two start dates need to be swapped

' to ' +
activationDateString +
'.\n';
const link = `https://finishlinebyner.com/projects/${wbsString}`;
const linkButtonText = 'Change Work Package';

await Promise.all(teams?.map((team) => sendMessage(team.slackId, message, link, linkButtonText)) ?? []);
};

async function pingBasedOnId(id: string) {
if (id) {
Comment thread
Steph375 marked this conversation as resolved.
const [user] = await getUsersWithSettings([id]);
if (user) {
const ping = userToSlackPing(user);
if (ping) return ping;
}
}
return '';
}
Loading