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

Feature/ideation endpoints v2 #20

Merged
merged 46 commits into from
Oct 25, 2023
Merged

Feature/ideation endpoints v2 #20

merged 46 commits into from
Oct 25, 2023

Conversation

awlFCCamp
Copy link

@awlFCCamp awlFCCamp commented Oct 16, 2023

Description

implemented service layer of the ideation GitHub issue

Issue link

#16
Fixes #16

Type of change for the service layer of ideation

  • create Ideation
  • get ProjectIdeas by VoyageTeamId
  • update Ideation
  • delete Ideation (only if ideation has no votes)
  • create Ideation Vote (only one allowed per user per ideation)
  • delete Ideation Vote

How Has This Been Tested?

I tested using Swagger
SM- Also tested via swagger

Checklist:

  • [ X] My code follows the style guidelines of this project
  • [ X] I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [X ] My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@awlFCCamp awlFCCamp closed this Oct 16, 2023
@jenny-alexander jenny-alexander requested review from jenny-alexander and removed request for Dan-Y-Ko October 17, 2023 04:05
prisma/schema.prisma Outdated Show resolved Hide resolved
prisma/schema.prisma Outdated Show resolved Hide resolved
src/ideation/dto/create-ideation-vote.dto.ts Outdated Show resolved Hide resolved
src/ideation/ideation.controller.ts Outdated Show resolved Hide resolved
src/ideation/ideation.service.ts Outdated Show resolved Hide resolved
src/ideation/ideation.service.ts Outdated Show resolved Hide resolved
@cherylli
Copy link
Collaborator

I also recommend changing the resource to plural form, like ideations as that's what nest does and consistent with the rest of the project

https://docs.nestjs.com/recipes/crud-generator

image

@Dan-Y-Ko Dan-Y-Ko self-requested a review October 18, 2023 22:49
Copy link
Collaborator

@Dan-Y-Ko Dan-Y-Ko left a comment

Choose a reason for hiding this comment

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

I'd like to see the methods in the controller and service more descriptive. I have no idea what create and update is supposed to refer to. Also use the same name in the controller and service (that is the convention).

Remember that we have to support editing project idea and increasing/decreasing votes. In a way, both could be applied to a method called "update", hence why it's not clear to me.

src/ideation/ideation.controller.ts Outdated Show resolved Hide resolved
@smurph7894 smurph7894 changed the title Feature/ideation endpoints v2 Draft: Feature/ideation endpoints v2 Oct 20, 2023
@smurph7894 smurph7894 changed the title Draft: Feature/ideation endpoints v2 Feature/ideation endpoints v2 Oct 20, 2023
@smurph7894 smurph7894 marked this pull request as draft October 20, 2023 01:18
yarn add class-validator
validators added
implemented ProjectIdea from schema
updated projectIdeaVotes property
Copy link
Collaborator

@cherylli cherylli left a comment

Choose a reason for hiding this comment

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

all endpoint works but all errors are just the default 500 server error. I'm not sure how much of these error handling are required for this.

Also, should a vote be automatically added when a person contribute to an idea? I mean the person should "like" that idea if they posted it?

voteCount is not needed as mentioned it can be obtained by the length of projectIdeaVotes

"projectIdeaVotes": [
      {
        "id": 2,
        "voyageTeamMemberId": 5,
        "projectIdeaId": 16,
        "createdAt": "2023-10-24T13:47:44.394Z",
        "updatedAt": "2023-10-24T13:47:44.394Z",
        "votedBy": {
          "id": 5,
          "userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
          "voyageTeamId": 3,
          "voyageRoleId": 7,
          "statusId": 4,
          "hrPerSprint": 15,
          "createdAt": "2023-10-24T13:30:54.444Z",
          "updatedAt": "2023-10-24T13:30:54.444Z",
          "member": {
            "id": "dd532498-16f7-4d32-b054-e0ed5518cb11",
            "avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
            "firstName": "Larry",
            "lastName": "Castro"
          }
        }
      }

@Dan-Y-Ko
Copy link
Collaborator

Dan-Y-Ko commented Oct 24, 2023

Idk how to group multiple things and leave a comment on them so I'll just comment here. Generally speaking, you should denote any methods that are not called by the controller as private methods. Not only for all the reasons why you'd want private methods, but it also helps us see easily which are just "utility" methods in the service.
These are just things I saw from glancing at the code. I'll test the endpoints tomorrow.

Does Nestjs have a way of denoting private methods or are you looking for grouping with a note? It's late but I'm not finding a private method yet from researching like what Java has :/

use private keyword https://www.typescriptlang.org/docs/handbook/2/classes.html#private Also I saw you wrote comment to denote them but that's not necessary. It's common convention to put private methods either at the top of the file or at the bottom. I have no preference to either.

@Dan-Y-Ko
Copy link
Collaborator

Dan-Y-Ko commented Oct 24, 2023

all endpoint works but all errors are just the default 500 server error. I'm not sure how much of these error handling are required for this.

Also, should a vote be automatically added when a person contribute to an idea? I mean the person should "like" that idea if they posted it?

voteCount is not needed as mentioned it can be obtained by the length of projectIdeaVotes

"projectIdeaVotes": [
      {
        "id": 2,
        "voyageTeamMemberId": 5,
        "projectIdeaId": 16,
        "createdAt": "2023-10-24T13:47:44.394Z",
        "updatedAt": "2023-10-24T13:47:44.394Z",
        "votedBy": {
          "id": 5,
          "userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
          "voyageTeamId": 3,
          "voyageRoleId": 7,
          "statusId": 4,
          "hrPerSprint": 15,
          "createdAt": "2023-10-24T13:30:54.444Z",
          "updatedAt": "2023-10-24T13:30:54.444Z",
          "member": {
            "id": "dd532498-16f7-4d32-b054-e0ed5518cb11",
            "avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
            "firstName": "Larry",
            "lastName": "Castro"
          }
        }
      }

Good point. I think we should be consistent and just add a vote for themself for everything in this project.

Editing this as I thought about it, let's worry about error handling for this pr specifically later as it's very high priority to get this merged.

@smurph7894 smurph7894 closed this Oct 24, 2023
@smurph7894 smurph7894 reopened this Oct 24, 2023
@smurph7894
Copy link
Contributor

sorry pressed the wrong button

@cherylli
Copy link
Collaborator

"projectIdeaVotes": [
      {
        "id": 2,
        "voyageTeamMemberId": 5,
        "projectIdeaId": 16,
        "createdAt": "2023-10-24T13:47:44.394Z",
        "updatedAt": "2023-10-24T13:47:44.394Z",
        "votedBy": {
          "id": 5,
          "userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
          "voyageTeamId": 3,
          "voyageRoleId": 7,
          "statusId": 4,
          "hrPerSprint": 15,
          "createdAt": "2023-10-24T13:30:54.444Z",
          "updatedAt": "2023-10-24T13:30:54.444Z",
          "member": {
            "id": "dd532498-16f7-4d32-b054-e0ed5518cb11",
            "avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
            "firstName": "Larry",
            "lastName": "Castro"
          }
        }
      }

sorry posted this but forgot to say anything about it, for this endpoint, I believe all these are not needed

"id": 5,
"userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
"voyageTeamId": 3,
"voyageRoleId": 7,
"statusId": 4,
"hrPerSprint": 15,
"createdAt": "2023-10-24T13:30:54.444Z",
"updatedAt": "2023-10-24T13:30:54.444Z",

private added to helper methods
create ideation also adds creators vote
delete ideation also removed creators vote
@Dan-Y-Ko
Copy link
Collaborator

"projectIdeaVotes": [
      {
        "id": 2,
        "voyageTeamMemberId": 5,
        "projectIdeaId": 16,
        "createdAt": "2023-10-24T13:47:44.394Z",
        "updatedAt": "2023-10-24T13:47:44.394Z",
        "votedBy": {
          "id": 5,
          "userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
          "voyageTeamId": 3,
          "voyageRoleId": 7,
          "statusId": 4,
          "hrPerSprint": 15,
          "createdAt": "2023-10-24T13:30:54.444Z",
          "updatedAt": "2023-10-24T13:30:54.444Z",
          "member": {
            "id": "dd532498-16f7-4d32-b054-e0ed5518cb11",
            "avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
            "firstName": "Larry",
            "lastName": "Castro"
          }
        }
      }

sorry posted this but forgot to say anything about it, for this endpoint, I believe all these are not needed

"id": 5,
"userId": "dd532498-16f7-4d32-b054-e0ed5518cb11",
"voyageTeamId": 3,
"voyageRoleId": 7,
"statusId": 4,
"hrPerSprint": 15,
"createdAt": "2023-10-24T13:30:54.444Z",
"updatedAt": "2023-10-24T13:30:54.444Z",

Which endpoint is this for?

@cherylli
Copy link
Collaborator

Which endpoint is this for?

return votes I think, should only need first name, last name and avatar, maybe id

prisma/schema.prisma Outdated Show resolved Hide resolved
@smurph7894
Copy link
Contributor

smurph7894 commented Oct 25, 2023

Which endpoint is this for?

return votes I think, should only need first name, last name and avatar, maybe id

The only endpoint that returns all that information is getIdeationsByVoyageTeam. I've removed the votedBy info from the response section ( info from the voyageTeamMember table). This is the updated current return:
[
{
"id": 1,
"title": "Write a poem",
"description": "A poem is a form of writing that tries to stimulate an emotional response or imaginative awareness within the reader. Many poems have a rhyming structure or follow an established format.",
"vision": "If you've never written poetry before, start by reading other writers' poems.",
"createdAt": "2023-10-24T09:05:20.506Z",
"contributedBy": {
"member": {
"id": "688fd40d-569b-4e5f-bf38-b81bfd67d95d",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=wavatar&r=x",
"firstName": "Joso",
"lastName": "Mađar"
}
},
"projectIdeaVotes": []
},
{
"id": 15,
"title": "newProjectIdea3",
"description": "test",
"vision": "test",
"createdAt": "2023-10-24T23:08:08.790Z",
"contributedBy": {
"member": {
"id": "5978bce0-51be-42e5-8aa8-04f0495b96ae",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
"firstName": "Larry",
"lastName": "Castro"
}
},
"projectIdeaVotes": [
{
"id": 7,
"voyageTeamMemberId": 2,
"projectIdeaId": 15,
"createdAt": "2023-10-24T23:08:08.800Z",
"updatedAt": "2023-10-24T23:08:08.800Z",
"votedBy": {
"member": {
"id": "5978bce0-51be-42e5-8aa8-04f0495b96ae",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
"firstName": "Larry",
"lastName": "Castro"
}
}
}
]
},
{
"id": 7,
"title": "Temperature Converter Website",
"description": "Developing a website that converts temperature recorded in one unit to another can be an excellent place for web developers to move forward in their web development journey.",
"vision": "The measuring units of the temperature recorded in a particular unit can be converted with a temperature converter, necessitating you to build a dropdown menu with temperature scales. You can also more functionality to the website by providing some other converters.",
"createdAt": "2023-10-24T09:05:20.532Z",
"contributedBy": {
"member": {
"id": "ac4107a2-b0fc-4f7f-84bb-3eaf5348ad70",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x",
"firstName": "Jessica",
"lastName": "Williamson"
}
},
"projectIdeaVotes": []
},
{
"id": 19,
"title": "Test Idea",
"description": "test",
"vision": "test",
"createdAt": "2023-10-25T01:49:08.425Z",
"contributedBy": {
"member": {
"id": "ac4107a2-b0fc-4f7f-84bb-3eaf5348ad70",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x",
"firstName": "Jessica",
"lastName": "Williamson"
}
},
"projectIdeaVotes": [
{
"id": 11,
"voyageTeamMemberId": 3,
"projectIdeaId": 19,
"createdAt": "2023-10-25T01:49:08.443Z",
"updatedAt": "2023-10-25T01:49:08.443Z",
"votedBy": {
"member": {
"id": "ac4107a2-b0fc-4f7f-84bb-3eaf5348ad70",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=robohash&r=x",
"firstName": "Jessica",
"lastName": "Williamson"
}
}
},
{
"id": 12,
"voyageTeamMemberId": 2,
"projectIdeaId": 19,
"createdAt": "2023-10-25T01:49:58.168Z",
"updatedAt": "2023-10-25T01:49:58.168Z",
"votedBy": {
"member": {
"id": "5978bce0-51be-42e5-8aa8-04f0495b96ae",
"avatar": "https://gravatar.com/avatar/3bfaef00e02a22f99e17c66e7a9fdd31?s=400&d=monsterid&r=x",
"firstName": "Larry",
"lastName": "Castro"
}
}
}
]
}
]

I removed a few objects so it wasn't as long as it was so some { may be off.

remove voyageTeamMember information from Get query results
making description and vision required per Figma
cherylli
cherylli previously approved these changes Oct 25, 2023
Copy link
Collaborator

@cherylli cherylli left a comment

Choose a reason for hiding this comment

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

looks good, more error handling can be added later

@Dan-Y-Ko
Copy link
Collaborator

/api/v1/teams/{teamId}/ideation-vote should have the project idea id in the paramter and not the body.
both delete endpoints should have user id moved to body.

Other than that, this looks good to merge. Great job on this Sarah :)

removed projectIdeaId requirement from create ideationVote
added dto to deleteIdeation and deleteIdeationVote to move userId to body from parameter
updating for userId to be in body and add Dto files
verify ids are uniform
update createIdeationVote endpoint parameters
remove userId from endpoint and add to body for deleteIdeation and deleteIdeationVote
@smurph7894
Copy link
Contributor

Both delete endpoints use a body for userId and ideation vote endpoint has ideationId moved to a parameter.

Copy link
Contributor

@jenny-alexander jenny-alexander left a comment

Choose a reason for hiding this comment

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

LGTM - great job taking in all comments and incorporating them into your code.
I tested endpoints locally.
Endpoints should be plural - we will take care of that in another task

@Dan-Y-Ko Dan-Y-Ko merged commit f143101 into dev Oct 25, 2023
1 check passed
@Dan-Y-Ko Dan-Y-Ko deleted the feature/ideation-endpoints-v2 branch October 25, 2023 16:58
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.

Create ideation endpoint
5 participants