Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e5fb6f7
Fix Logout
Peyton-McKee Jan 23, 2025
8482509
Debug Google Calendar Creation
Peyton-McKee Jan 23, 2025
7f01c90
Dont Create Calendar for now
Peyton-McKee Jan 23, 2025
b8683d8
Optimize Projects
Peyton-McKee Jan 24, 2025
f35f08e
Remove Console logs
Peyton-McKee Jan 24, 2025
82c9756
Upgrade Node Version On Github Runners
Peyton-McKee Jan 24, 2025
12fda02
Fix Tests
Peyton-McKee Jan 24, 2025
2dac67d
Fix Frontend Tests
Peyton-McKee Jan 24, 2025
9dee77d
Merge pull request #3168 from Northeastern-Electric-Racing/Optimize-P…
Peyton-McKee Jan 24, 2025
24359f7
Fix Boms
Peyton-McKee Jan 24, 2025
88763da
Fix Sizing of Work Package Name
Peyton-McKee Jan 24, 2025
8721a43
Fix Logout, Fix Work Package names, Fix Bom Material Editing, Fix Edi…
Peyton-McKee Jan 24, 2025
05a2104
Correct Logout Route
Peyton-McKee Jan 24, 2025
01de239
Fix Incorrect Date Setting Design Review
Peyton-McKee Jan 25, 2025
4914ad6
Push to Login
Peyton-McKee Jan 25, 2025
8bb05fa
Fix Not Being able to singly select items
Peyton-McKee Jan 27, 2025
b22fc7d
Change File Name Automatically
Peyton-McKee Jan 28, 2025
f470e64
Fix Filename
Peyton-McKee Jan 28, 2025
13b57fb
Remove Frontend Checks
Peyton-McKee Jan 29, 2025
98a23ac
Update Frontend To Have Correct Names
Peyton-McKee Jan 29, 2025
12dbaa5
Fix Filename Verification Logic
Peyton-McKee Jan 29, 2025
ae46ac9
fixed error?
vsp05 Feb 2, 2025
c070cf9
Merge pull request #3179 from Northeastern-Electric-Racing/20250202-f…
walker-sean Feb 3, 2025
12e1c9f
#3170 controller/route/service
cielbellerose Feb 4, 2025
c304f13
Merge branch 'develop' of https://github.com/Northeastern-Electric-Ra…
Peyton-McKee Feb 5, 2025
2bfef4c
Use New Name from All Receipts
Peyton-McKee Feb 5, 2025
e4a6f2c
Merge branch 'multitenancy' into develop
Peyton-McKee Feb 5, 2025
fd28276
Merge branch 'develop' into 3170-create-getpartreview-faqs
cielbellerose Feb 5, 2025
1ff3758
testing updates
cielbellerose Feb 6, 2025
ab941cd
Revert "testing updates"
cielbellerose Feb 6, 2025
3a2e957
Revert "Merge branch 'develop' into 3170-create-getpartreview-faqs"
cielbellerose Feb 6, 2025
90afe68
Unit Tests added
cielbellerose Feb 6, 2025
9bf2c6e
moved tests to unmocked
cielbellerose Feb 6, 2025
92d8a3a
unit test updates
cielbellerose Feb 6, 2025
06405d3
#3170 seed data for postman
cielbellerose Feb 11, 2025
68c1742
#3193 prettier/linting
cielbellerose Feb 11, 2025
d13794f
#3193 null regularFaqId fix
cielbellerose Feb 11, 2025
34d4894
#3193 transformer attempted
cielbellerose Feb 19, 2025
88b111b
#3170 transformer for faqs
cielbellerose Feb 20, 2025
36d09ef
#3170 prettier and lint fixes + test fix
cielbellerose Feb 20, 2025
6f8c3cd
#3170 dateDeleted null vs undefined issue
cielbellerose Feb 20, 2025
f7f22ef
#3170 tests updated
cielbellerose Feb 25, 2025
7869668
#3170 linting test fix
cielbellerose Feb 25, 2025
2b59ccb
#3170 tests actually fixed
cielbellerose Feb 25, 2025
11e1c05
#3170 deep equal test issue fixed
cielbellerose Feb 25, 2025
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
9 changes: 9 additions & 0 deletions src/backend/src/controllers/organizations.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,13 @@ export default class OrganizationsController {
next(error);
}
}

static async getAllPartReviewFAQS(req: Request, res: Response, next: NextFunction) {
try {
const partReviewFAQS = await OrganizationsService.getAllPartReviewFAQs(req.organization.organizationId);
res.status(200).json(partReviewFAQS);
} catch (error: unknown) {
next(error);
}
}
}
12 changes: 12 additions & 0 deletions src/backend/src/prisma-query-args/faq.query.args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Prisma } from '@prisma/client';
import { getUserQueryArgs } from './user.query-args';

export type FaqQueryArgs = ReturnType<typeof getFaqQueryArgs>;

export const getFaqQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.FrequentlyAskedQuestionDefaultArgs>()({
include: {
userCreated: getUserQueryArgs(organizationId),
userDeleted: getUserQueryArgs(organizationId)
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CREATE TYPE "Review_Status" AS ENUM ('IN_PROGRESS', 'READY_FOR_REVIEW', 'IN_REVI
-- DropForeignKey
ALTER TABLE "FrequentlyAskedQuestion" DROP CONSTRAINT "FrequentlyAskedQuestion_organizationId_fkey";
ALTER TABLE "FrequentlyAskedQuestion" RENAME COLUMN "organizationId" TO "regularFaqOrgId";
ALTER TABLE "FrequentlyAskedQuestion" ALTER "regularFaqOrgId" DROP NOT NULL;
ALTER TABLE "FrequentlyAskedQuestion" ADD COLUMN "partReviewFaqOrgId" TEXT;
ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_regularFaqOrgId_fkey" FOREIGN KEY ("regularFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_partReviewFaqOrgId_fkey" FOREIGN KEY ("partReviewFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE;
Expand Down
11 changes: 11 additions & 0 deletions src/backend/src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,17 @@ const performSeed: () => Promise<void> = async () => {
ner
);

await prisma.frequentlyAskedQuestion.create({
data: {
faqId: '1',
question: 'question',
answer: 'answer',
userCreated: { connect: { userId: batman.userId } },
dateCreated: new Date(),
partReviewFaqOrg: { connect: { organizationId: ner.organizationId } }
}
});

await AnnouncementService.createAnnouncement(
'Welcome to Finishline!',
[regina.userId],
Expand Down
3 changes: 3 additions & 0 deletions src/backend/src/routes/organizations.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ organizationRouter.post(
nonEmptyString(body('workspaceId')),
OrganizationsController.setSlackWorkspaceId
);

organizationRouter.get('/getAllPartReviewFAQs', OrganizationsController.getAllPartReviewFAQS);

export default organizationRouter;
16 changes: 16 additions & 0 deletions src/backend/src/services/organizations.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { uploadFile } from '../utils/google-integration.utils';
import { getProjects } from '../utils/projects.utils';
import { getProjectQueryArgs } from '../prisma-query-args/projects.query-args';
import projectTransformer from '../transformers/projects.transformer';
import { faqTransformer } from '../transformers/faq.transformer';
import { getFaqQueryArgs } from '../prisma-query-args/faq.query.args';

export default class OrganizationsService {
/**
Expand Down Expand Up @@ -407,4 +409,18 @@ export default class OrganizationsService {

return updatedOrg;
}

/**
* Gets all part review FAQs for the given organization Id
* @param organizationId organization Id of the FAQ
* @returns all the part review faqs from the given organization
*/
static async getAllPartReviewFAQs(organizationId: string) {
const partReviewFAQs = await prisma.frequentlyAskedQuestion.findMany({
where: { dateDeleted: null, partReviewFaqOrgId: organizationId },
...getFaqQueryArgs(organizationId)
});

return partReviewFAQs.map(faqTransformer);
}
}
7 changes: 5 additions & 2 deletions src/backend/src/services/recruitment.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { isAdmin } from 'shared';
import prisma from '../prisma/prisma';
import { AccessDeniedAdminOnlyException, DeletedException, NotFoundException } from '../utils/errors.utils';
import { userHasPermission } from '../utils/users.utils';
import { faqTransformer } from '../transformers/faq.transformer';
import { getFaqQueryArgs } from '../prisma-query-args/faq.query.args';

export default class RecruitmentServices {
/**
Expand Down Expand Up @@ -106,10 +108,11 @@ export default class RecruitmentServices {
*/
static async getAllOrganizationFaqs(organization: Organization) {
const allFaqs = await prisma.frequentlyAskedQuestion.findMany({
where: { dateDeleted: null, regularFaqOrgId: organization.organizationId }
where: { dateDeleted: null, regularFaqOrgId: organization.organizationId },
...getFaqQueryArgs(organization.organizationId)
});

return allFaqs;
return allFaqs.map(faqTransformer);
}

/*
Expand Down
13 changes: 13 additions & 0 deletions src/backend/src/transformers/faq.transformer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Prisma } from '@prisma/client';
import { FrequentlyAskedQuestion } from 'shared';
import { FaqQueryArgs } from '../prisma-query-args/faq.query.args';
import { userTransformer } from './user.transformer';

export const faqTransformer = (faq: Prisma.FrequentlyAskedQuestionGetPayload<FaqQueryArgs>): FrequentlyAskedQuestion => ({
faqId: faq.faqId,
question: faq.question,
answer: faq.answer,
userCreated: userTransformer(faq.userCreated),
dateCreated: faq.dateCreated,
dateDeleted: faq.dateDeleted ?? undefined
});
6 changes: 5 additions & 1 deletion src/backend/tests/unit/recruitment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ describe('Recruitment Tests', () => {
organization
);
const result = await RecruitmentServices.getAllOrganizationFaqs(organization);
expect(result).toStrictEqual([faq1, faq2]);
expect(result).toHaveLength(2);
expect(result[0].question).toEqual(faq1.question);
expect(result[0].answer).toEqual(faq1.answer);
expect(result[1].question).toEqual(faq2.question);
expect(result[1].answer).toEqual(faq2.answer);
});

describe('Edit FAQ', () => {
Expand Down
67 changes: 67 additions & 0 deletions src/backend/tests/unmocked/organization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,71 @@ describe('Organization Tests', () => {
expect(allContacts.some((contact) => contact.userId === testSuperman.userId)).toBeTruthy();
});
});

describe('Get all part FAQS', () => {
it('Succeeds and gets all part review FAQS in the organization', async () => {
const testBatman = await createTestUser(batmanAppAdmin, orgId);
const faq1 = await prisma.frequentlyAskedQuestion.create({
data: {
faqId: '1',
question: 'question1',
answer: 'answer1',
userCreated: { connect: { userId: testBatman.userId } },
dateCreated: new Date(),
partReviewFaqOrg: { connect: { organizationId: orgId } }
}
});
const faq2 = await prisma.frequentlyAskedQuestion.create({
data: {
faqId: '2',
question: 'question2',
answer: 'answer2',
userCreated: { connect: { userId: testBatman.userId } },
dateCreated: new Date(),
partReviewFaqOrg: { connect: { organizationId: orgId } }
}
});
const partReviews = await OrganizationsService.getAllPartReviewFAQs(orgId);
expect(partReviews).toHaveLength(2);
expect(partReviews[0].question).toEqual(faq1.question);
expect(partReviews[0].answer).toEqual(faq1.answer);
expect(partReviews[1].question).toEqual(faq2.question);
expect(partReviews[1].answer).toEqual(faq2.answer);
});

it('Retrieves empty list of part review FAQS in the organization', async () => {
const partReviews = await OrganizationsService.getAllPartReviewFAQs(orgId);
expect(partReviews).toHaveLength(0);
});

it('Does not retrieve regular FAQS in the organization', async () => {
const testBatman = await createTestUser(batmanAppAdmin, orgId);
const partFaq = await prisma.frequentlyAskedQuestion.create({
data: {
faqId: '1',
question: 'faq question',
answer: 'faq answer',
userCreated: { connect: { userId: testBatman.userId } },
dateCreated: new Date(),
partReviewFaqOrg: { connect: { organizationId: orgId } }
}
});
const regularFaq = await prisma.frequentlyAskedQuestion.create({
data: {
faqId: '2',
question: 'regular question',
answer: 'regular answer',
userCreated: { connect: { userId: testBatman.userId } },
dateCreated: new Date(),
regularFaqOrg: { connect: { organizationId: orgId } }
}
});
const partReviews = await OrganizationsService.getAllPartReviewFAQs(orgId);
expect(partReviews).toHaveLength(1);
expect(partReviews[0].question).toEqual(partFaq.question);
expect(partReviews[0].answer).toEqual(partFaq.answer);
expect(partReviews[0].question).not.toEqual(regularFaq.question);
expect(partReviews[0].answer).not.toEqual(regularFaq.answer);
});
});
});
6 changes: 5 additions & 1 deletion src/backend/tests/unmocked/recruitment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ describe('Recruitment Tests', () => {
organization
);
const result = await RecruitmentServices.getAllOrganizationFaqs(organization);
expect(result).toStrictEqual([faq1, faq2]);
expect(result).toHaveLength(2);
expect(result[0].question).toEqual(faq1.question);
expect(result[0].answer).toEqual(faq1.answer);
expect(result[1].question).toEqual(faq2.question);
expect(result[1].answer).toEqual(faq2.answer);
});

describe('Edit FAQ', () => {
Expand Down