Skip to content

Commit 76a6055

Browse files
authored
Merge pull request #4153 from Northeastern-Electric-Racing/4090-maintenance---schema-changes-move-notifications-to-event-level
4090 maintenance schema changes move notifications to event level
2 parents 58b1740 + 036865f commit 76a6055

11 files changed

Lines changed: 104 additions & 71 deletions

File tree

src/backend/src/controllers/calendar.controllers.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ export default class CalendarController {
2121
documents,
2222
description,
2323
onlyHeadsOrAbove,
24-
requiresConfirmation,
25-
sendSlackNotifications
24+
requiresConfirmation
2625
} = req.body;
2726

2827
const eventType = await CalendarService.createEventType(
@@ -43,8 +42,7 @@ export default class CalendarController {
4342
documents,
4443
description,
4544
onlyHeadsOrAbove,
46-
requiresConfirmation,
47-
sendSlackNotifications
45+
requiresConfirmation
4846
);
4947
res.status(200).json(eventType);
5048
} catch (error: unknown) {
@@ -205,8 +203,7 @@ export default class CalendarController {
205203
documents,
206204
description,
207205
onlyHeadsOrAbove,
208-
requiresConfirmation,
209-
sendSlackNotifications
206+
requiresConfirmation
210207
} = req.body;
211208

212209
const eventType = await CalendarService.editEventType(
@@ -228,8 +225,7 @@ export default class CalendarController {
228225
documents,
229226
description,
230227
onlyHeadsOrAbove,
231-
requiresConfirmation,
232-
sendSlackNotifications
228+
requiresConfirmation
233229
);
234230
res.status(200).json(eventType);
235231
} catch (error: unknown) {
@@ -278,7 +274,8 @@ export default class CalendarController {
278274
questionDocumentLink,
279275
location,
280276
zoomLink,
281-
description
277+
description,
278+
sendSlackNotifications
282279
} = req.body;
283280

284281
const parsedScheduleSlots = scheduleSlots.map((slot: any) => ({
@@ -302,6 +299,7 @@ export default class CalendarController {
302299
workPackageIds,
303300
parsedScheduleSlots,
304301
parsedInitialDateScheduled,
302+
sendSlackNotifications,
305303
teamTypeId,
306304
questionDocumentLink,
307305
location,
@@ -332,7 +330,8 @@ export default class CalendarController {
332330
questionDocumentLink,
333331
location,
334332
zoomLink,
335-
description
333+
description,
334+
sendSlackNotifications
336335
} = req.body;
337336

338337
const event = await CalendarService.editEvent(
@@ -348,6 +347,7 @@ export default class CalendarController {
348347
machineryIds,
349348
workPackageIds,
350349
documents,
350+
sendSlackNotifications,
351351
teamTypeId,
352352
questionDocumentLink,
353353
location,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- AlterTable
2+
ALTER TABLE "Event" ADD COLUMN "sendSlackNotifications" BOOLEAN NOT NULL DEFAULT false;
3+
4+
-- Backfill Event.sendSlackNotifications from Event_Type before dropping the old column
5+
UPDATE "Event" e
6+
SET "sendSlackNotifications" = true
7+
FROM "Event_Type" et
8+
WHERE e."eventTypeId" = et."eventTypeId"
9+
AND et."sendSlackNotifications" = true;
10+
11+
-- AlterTable
12+
ALTER TABLE "Event_Type" DROP COLUMN "sendSlackNotifications";

src/backend/src/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ model Event {
11801180
description String?
11811181
notificationSlackThreads Message_Info[]
11821182
calendarEventIds String[]
1183+
sendSlackNotifications Boolean @default(false)
11831184
}
11841185

11851186
model Calendar {
@@ -1222,7 +1223,6 @@ model Event_Type {
12221223
description Boolean
12231224
onlyHeadsOrAboveForEventCreation Boolean
12241225
requiresConfirmation Boolean
1225-
sendSlackNotifications Boolean
12261226
events Event[]
12271227
organizationId String
12281228
organization Organization @relation(fields: [organizationId], references: [organizationId])

src/backend/src/prisma/seed.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4806,7 +4806,6 @@ const performSeed: () => Promise<void> = async () => {
48064806
false,
48074807
true,
48084808
false,
4809-
false,
48104809
false
48114810
);
48124811

@@ -4829,7 +4828,6 @@ const performSeed: () => Promise<void> = async () => {
48294828
true,
48304829
true,
48314830
false,
4832-
true,
48334831
true
48344832
);
48354833

@@ -4852,7 +4850,6 @@ const performSeed: () => Promise<void> = async () => {
48524850
true,
48534851
false,
48544852
false,
4855-
false,
48564853
false
48574854
);
48584855

@@ -4875,7 +4872,6 @@ const performSeed: () => Promise<void> = async () => {
48754872
false,
48764873
false,
48774874
false,
4878-
false,
48794875
false
48804876
);
48814877

@@ -4898,6 +4894,7 @@ const performSeed: () => Promise<void> = async () => {
48984894
}
48994895
],
49004896
undefined,
4897+
true,
49014898
mechanical.teamTypeId,
49024899
undefined,
49034900
'Conference Room A',
@@ -4939,6 +4936,7 @@ const performSeed: () => Promise<void> = async () => {
49394936
}
49404937
],
49414938
undefined,
4939+
false,
49424940
mechanical.teamTypeId,
49434941
undefined,
49444942
'Conference Room A',
@@ -4965,6 +4963,7 @@ const performSeed: () => Promise<void> = async () => {
49654963
}
49664964
],
49674965
undefined,
4966+
false,
49684967
mechanical.teamTypeId,
49694968
undefined,
49704969
'Conference Room A',
@@ -4991,6 +4990,7 @@ const performSeed: () => Promise<void> = async () => {
49914990
}
49924991
],
49934992
undefined,
4993+
true,
49944994
mechanical.teamTypeId,
49954995
undefined,
49964996
'Conference Room A',
@@ -5017,6 +5017,7 @@ const performSeed: () => Promise<void> = async () => {
50175017
}
50185018
],
50195019
undefined,
5020+
true,
50205021
mechanical.teamTypeId,
50215022
undefined,
50225023
'Conference Room A',
@@ -5043,6 +5044,7 @@ const performSeed: () => Promise<void> = async () => {
50435044
}
50445045
],
50455046
undefined,
5047+
false,
50465048
mechanical.teamTypeId,
50475049
undefined,
50485050
'Conference Room A',
@@ -5063,6 +5065,7 @@ const performSeed: () => Promise<void> = async () => {
50635065
[workPackage3.id],
50645066
[],
50655067
weeksFromNow(1),
5068+
true,
50665069
software.teamTypeId,
50675070
'https://docs.google.com/document/d/2_example',
50685071
'Conference Room B',
@@ -5089,6 +5092,7 @@ const performSeed: () => Promise<void> = async () => {
50895092
}
50905093
],
50915094
undefined,
5095+
true,
50925096
electrical.teamTypeId,
50935097
'https://docs.google.com/document/d/3_example',
50945098
undefined,
@@ -5115,6 +5119,7 @@ const performSeed: () => Promise<void> = async () => {
51155119
}
51165120
],
51175121
undefined,
5122+
false,
51185123
mechanical.teamTypeId,
51195124
undefined,
51205125
undefined,

src/backend/src/routes/calendar.routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ calendarRouter.post(
6464
body('description').isBoolean(),
6565
body('onlyHeadsOrAbove').isBoolean(),
6666
body('requiresConfirmation').isBoolean(),
67-
body('sendSlackNotifications').isBoolean(),
6867
validateInputs,
6968
CalendarController.createEventType
7069
);
@@ -88,7 +87,6 @@ calendarRouter.post(
8887
body('description').isBoolean(),
8988
body('onlyHeadsOrAbove').isBoolean(),
9089
body('requiresConfirmation').isBoolean(),
91-
body('sendSlackNotifications').isBoolean(),
9290
validateInputs,
9391
CalendarController.editEventType
9492
);
@@ -119,6 +117,7 @@ calendarRouter.post(
119117
isDate(body('scheduleSlots.*.startTime')),
120118
isDate(body('scheduleSlots.*.endTime')),
121119
body('scheduleSlots.*.allDay').isBoolean(),
120+
body('sendSlackNotifications').isBoolean(),
122121
validateInputs,
123122
CalendarController.createEvent
124123
);
@@ -147,6 +146,7 @@ calendarRouter.post(
147146
nonEmptyString(body('documents.*.googleFileId')),
148147
body('questionDocumentLink').optional().isString(),
149148
body('description').optional().isString(),
149+
body('sendSlackNotifications').isBoolean(),
150150
validateInputs,
151151
CalendarController.editEvent
152152
);

0 commit comments

Comments
 (0)