Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #747 from Northeastern-Electric-Racing/#666-remove…
Browse files Browse the repository at this point in the history
…-spread-operator

#666 - Removed the spread operator wherever it appeared in the code
  • Loading branch information
anthonybernardi authored Jul 23, 2022
2 parents 701518d + d3a85a3 commit e0a03a0
Showing 1 changed file with 51 additions and 21 deletions.
72 changes: 51 additions & 21 deletions src/backend/functions/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ const manyRelationArgs = Prisma.validator<Prisma.ProjectArgs>()({
otherConstraints: true,
workPackages: {
include: {
wbsElement: { include: { changes: { include: { implementer: true } } } },
wbsElement: {
include: {
projectLead: true,
projectManager: true,
changes: { include: { implementer: true } }
}
},
dependencies: true,
expectedActivities: true,
deliverables: true
Expand All @@ -66,7 +72,13 @@ const uniqueRelationArgs = Prisma.validator<Prisma.WBS_ElementArgs>()({
otherConstraints: true,
workPackages: {
include: {
wbsElement: { include: { changes: { include: { implementer: true } } } },
wbsElement: {
include: {
projectLead: true,
projectManager: true,
changes: { include: { implementer: true } }
}
},
dependencies: true,
expectedActivities: true,
deliverables: true
Expand Down Expand Up @@ -94,8 +106,9 @@ const wbsNumOf = (element: WBS_Element): WbsNumber => ({
});

export const descBulletConverter = (descBullet: Description_Bullet): DescriptionBullet => ({
...descBullet,
id: descBullet.descriptionId,
detail: descBullet.detail,
dateAdded: descBullet.dateAdded,
dateDeleted: descBullet.dateDeleted ?? undefined
});

Expand All @@ -110,25 +123,32 @@ const projectTransformer = (
const wbsNum = wbsNumOf(wbsElement);

return {
...project,
...wbsElement,
id: project.projectId,
projectManager: wbsElement.projectManager ?? undefined,
projectLead: wbsElement.projectLead ?? undefined,
wbsNum,
dateCreated: wbsElement.dateCreated,
name: wbsElement.name,
status: convertStatus(wbsElement.status),
projectLead: wbsElement.projectLead ?? undefined,
projectManager: wbsElement.projectManager ?? undefined,
changes: wbsElement.changes.map((change) => ({
...change,
wbsNum
changeId: change.changeId,
changeRequestId: change.changeRequestId,
wbsNum,
implementer: change.implementer,
detail: change.detail,
dateImplemented: change.dateImplemented
})),
wbsNum,
summary: project.summary,
budget: project.budget,
gDriveLink: project.googleDriveFolderLink ?? undefined,
slideDeckLink: project.slideDeckLink ?? undefined,
taskListLink: project.taskListLink ?? undefined,
slideDeckLink: project.slideDeckLink ?? undefined,
bomLink: project.bomLink ?? undefined,
otherConstraints: project.otherConstraints.map(descBulletConverter),
features: project.features.map(descBulletConverter),
goals: project.goals.map(descBulletConverter),
rules: project.rules,
duration: project.workPackages.reduce((prev, curr) => prev + curr.duration, 0),
goals: project.goals.map(descBulletConverter),
features: project.features.map(descBulletConverter),
otherConstraints: project.otherConstraints.map(descBulletConverter),
workPackages: project.workPackages.map((workPackage) => {
const endDate = calculateEndDate(workPackage.startDate, workPackage.duration);
const expectedProgress = calculatePercentExpectedProgress(
Expand All @@ -138,21 +158,31 @@ const projectTransformer = (
);

return {
...workPackage,
...workPackage.wbsElement,
id: workPackage.workPackageId,
wbsNum: wbsNumOf(workPackage.wbsElement),
dateCreated: workPackage.wbsElement.dateCreated,
name: workPackage.wbsElement.name,
status: convertStatus(workPackage.wbsElement.status),
projectLead: workPackage.wbsElement.projectLead ?? undefined,
projectManager: workPackage.wbsElement.projectManager ?? undefined,
changes: workPackage.wbsElement.changes.map((change) => ({
changeId: change.changeId,
changeRequestId: change.changeRequestId,
wbsNum: wbsNumOf(workPackage.wbsElement),
implementer: change.implementer,
detail: change.detail,
dateImplemented: change.dateImplemented
})),
orderInProject: workPackage.orderInProject,
progress: workPackage.progress,
startDate: workPackage.startDate,
endDate,
duration: workPackage.duration,
expectedProgress,
timelineStatus: calculateTimelineStatus(workPackage.progress, expectedProgress),
dependencies: workPackage.dependencies.map(wbsNumOf),
expectedActivities: workPackage.expectedActivities.map(descBulletConverter),
deliverables: workPackage.deliverables.map(descBulletConverter),
changes: workPackage.wbsElement.changes.map((change) => ({
...change,
wbsNum: wbsNumOf(workPackage.wbsElement)
}))
deliverables: workPackage.deliverables.map(descBulletConverter)
};
})
};
Expand Down

0 comments on commit e0a03a0

Please sign in to comment.