Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3169 getparttags endpoint #3207

Open
wants to merge 4 commits into
base: feature/cad-project-file-review
Choose a base branch
from

Conversation

Aryan0102
Copy link
Contributor

Changes

Added new route at /organizations/getAllPartTags for #3169
Added service function using given organization id and returns an array of part tags.
Added a controller and parts-review.types.ts in shared types
Unit Tests

Notes

Could not do extensive postman tests, but unit tests passed

Test Cases

No organizationId, empty parts array, array with 2 parts

Screenshots

Screenshot 2025-02-06 at 9 43 15 PM

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please review the contributor guide and reach out to your Tech Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • All commits are tagged with the ticket number
  • No linting errors / newline at end of file warnings
  • All code follows repository-configured prettier formatting
  • No merge conflicts
  • All checks passing
  • Screenshots of UI changes (see Screenshots section)
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • No yarn.lock changes (unless dependencies have changed)
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #3169

@Aryan0102 Aryan0102 requested review from Zwendle and chpy04 February 7, 2025 02:58
@chpy04 chpy04 changed the base branch from develop to feature/cad-project-file-review February 7, 2025 15:45
Copy link
Contributor

@chpy04 chpy04 left a comment

Choose a reason for hiding this comment

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

Really good job. For the postman tests, can you include a couple part tags in the seed data and show that they show up in the get request

static async getAllPartTags(organizationId: string) {
const organization = await prisma.organization.findUnique({
where: { organizationId }
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Because the organization is pulled from the request and not an input from the user, you don't need to check for a notFoundException here. If the organization id for whatever reason did not exist here, it would be a problem on our end not the requester's end. Instead you can just get rid of this check

return prisma.partTag.findMany({
where: { organizationId },
select: {
partTagId: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need to include partTagId: true here

name: string;
colorHexCode: string;
dateCreated: Date;
dateDeleted?: Date;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't include dateDeleted in the shared type. If it was deleted, people should not be seeing it on the frontend

}

return prisma.partTag.findMany({
where: { organizationId },
Copy link
Contributor

Choose a reason for hiding this comment

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

Only return partTags where dateDeleted is null

const partTags = await OrganizationsService.getAllPartTags(organizationID);
expect(partTags.length).toEqual(2);
expect(partTags.some((tag) => tag.partTagId === '123')).toBeTruthy();
expect(partTags.some((tag) => tag.partTagId === '456')).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a partTag to a different organization, and a partTag that is deleted, and check that these are not in the result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAD/Project File Reviews] - create getpartTags endpoint
2 participants