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

#159987730 Users should be able to like or dislike comment made on an article. #41

Merged
merged 3 commits into from
Sep 12, 2018

Conversation

emekafredy
Copy link
Contributor

What does this PR do?

Create endpoints for to like or dislike article comments

Description of Task to be completed?

Create CommentLike model and migration file

Write unit tests for feature

Create endpoint

  • Like comment POST api/articles/<article_slug>/comments/<commentId>/like
  • Dislike comment POST api/articles/<article_slug>/comments/<commentId>/dislike

How should this be manually tested?

  • Clone the repo
  • cd into the 'Thor-ah'
  • Run 'npm install'
  • Use the .env.sample format to create a .env file
  • Run 'npm run migrate'
  • Run 'npm run start:dev'

Any background context you want to provide?

N/A

What are the relevant pivotal tracker stories?

159987730

@coveralls
Copy link

coveralls commented Sep 11, 2018

Pull Request Test Coverage Report for Build 349

  • 154 of 157 (98.09%) changed or added relevant lines in 10 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 92.874%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server/controllers/comments.js 39 42 92.86%
Totals Coverage Status
Change from base Build 345: 0.3%
Covered Lines: 1348
Relevant Lines: 1422

💛 - Coveralls

Copy link
Contributor

@CEOehis CEOehis left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lauragift21 lauragift21 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lauragift21 lauragift21 left a comment

Choose a reason for hiding this comment

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

For naming your models, you can add underscore between the words making it comment_like.js.

Copy link
Contributor

@lauragift21 lauragift21 left a comment

Choose a reason for hiding this comment

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

LGTM

@emekafredy emekafredy force-pushed the ft-create-comment-likes-endpoint-159987730 branch 2 times, most recently from 162d1cf to c9028e0 Compare September 11, 2018 13:33
@emekafredy
Copy link
Contributor Author

@lauragift21 This has been resolved

}

/**
* @description get number of likes and dislikes in an article
Copy link
Contributor

Choose a reason for hiding this comment

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

misleading comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I will correct this

if (commentReaction.reaction === '1') {
commentReactions.likes += 1;
} else if (commentReaction.reaction === '0') {
commentReactions.dislikes += 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

a better implementation is to find all where reaction === 0 or reaction === 1 and then total number of likes would be the length of the returned value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I will also work on this

Copy link
Contributor

@aknwosu aknwosu left a comment

Choose a reason for hiding this comment

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

add a function to check if the current logged in user already liked or disliked a comment so it can be used to format the view in the front end

…rticles

- define CommentLikes Model and its association with comments and users.
- write unit tests for comment like model and route.
- create endpoints for authenticated users to like or dislike comments made on articles.

[Delivers #159987730]
…rticles

- redefine model to store integers (0, 1) for dislikes and likes
- write endpoint to get all reactions of a comment

[Delivers #159987730]
@emekafredy emekafredy force-pushed the ft-create-comment-likes-endpoint-159987730 branch from 3a9dd91 to b6f2003 Compare September 12, 2018 10:54
…rticles

- Refactor code on getting the number of likes and dislikes in a comment.
- Define an endpoint to check if the current logged in user already liked or disliked a comment.

[Delivers #159987730]
@emekafredy emekafredy force-pushed the ft-create-comment-likes-endpoint-159987730 branch from b6f2003 to fcbb03e Compare September 12, 2018 11:33
@aknwosu aknwosu merged commit e6df509 into develop Sep 12, 2018
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.

5 participants