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

#168781692 add and view comment #40

Merged
merged 1 commit into from
Nov 1, 2019
Merged

Conversation

ngireric123
Copy link
Collaborator

@ngireric123 ngireric123 commented Oct 31, 2019

What does this PR do?

  • Add and view comments

Description of Task to be completed?

  • add the possibility for line manager and owner of the request to add a comment on the request
  • add the possibility for line manager and owner of the request to view a comment on the request

How should this be manually tested?

  • Browse to the repo directory
  • navigate to Ft-comment-168781692 branch
  • Run npm install
  • run sequelize db:migrate
  • run sequelize db:seed:all
  • run npm run dev

Any background context you want to provide?

To add a comment

  • In Postman Provide a login bearer token
  • Fill the body with comment field
  • send a POST request to http://localhost:<:port>/api/v1/comments/:id

To view a comment

  • In Postman Provide a login bearer token
  • send a GET request to http://localhost:<:port>/api/v1/comments/:id

What are the relevant pivotal tracker stories?

#168781692

Screenshots (if appropriate)

image

Questions:

N/A

@ngireric123 ngireric123 added the WIP Work In Progress label Oct 31, 2019
@ngireric123 ngireric123 changed the title feature(add_comment): add and view comment #168781692 add and view comment Oct 31, 2019
@ngireric123 ngireric123 added Ready For Review and removed WIP Work In Progress labels Oct 31, 2019
Copy link
Contributor

@alainmateso alainmateso left a comment

Choose a reason for hiding this comment

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

Great job Eric. Kindly change the message that you return when posting a comment and make it comment-related. I think the user is posting a comment not updating a request. Other than that, well done.

static async addComment(req, res) {
const { comment } = req.body;
const { id } = req.user.payload;
const requestId = parseInt(req.params.id, 10);
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 new line here

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line

try {
const requestId = parseInt(req.params.id, 10);
const comments = await models.comments.findAll({
where: { requestId }
Copy link
Contributor

Choose a reason for hiding this comment

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

This gets all comments on a request even the soft deleted ones. Add a condition to get comments only when the deleted= false


const { requests, users } = models;

const commentMiddle = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Get this a better name please

import commentMiddleware from '../../middlewares/commentMiddleware';

const router = new Router();

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line

const router = new Router();

const { addComment, getComments } = commentsController;

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line

const { addComment, getComments } = commentsController;

const { validateComment } = InputValidation;

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line

chai.use(chaiHttp);

const id = mockdata.verifiedUser1.id;

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line

return res.send(error);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line

Copy link
Contributor

@nakiwuge nakiwuge left a comment

Choose a reason for hiding this comment

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

@ngireric123 good job. Kindly work on the feedback below.

  • Return the user object you can return id, username and email when retrieving comments
  • Add your endpoints to swagger
  • Check out the comments I have left on the pr

        - create one endpoint for add/ view comment

        - create one controller for changeStatus

        - create a helper for comment

        - create a routes for API

        [starts #168781692]
@nakiwuge nakiwuge merged commit 9cd173d into develop Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants