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

Vote for ideas #51

Merged
merged 5 commits into from
Mar 27, 2018
Merged

Vote for ideas #51

merged 5 commits into from
Mar 27, 2018

Conversation

mrkvon
Copy link
Member

@mrkvon mrkvon commented Mar 14, 2018

  • add a vote to idea
  • remove a vote from idea
  • show how many up and down votes idea has, show if and how the current user voted
  • maybe change value of a vote (won't do now) (PATCH vote #52)

@mrkvon mrkvon requested a review from agatatalita March 14, 2018 13:58
use it to vote for comments
@mrkvon mrkvon changed the title WIP: Vote for ideas Vote for ideas Mar 25, 2018
@mrkvon mrkvon mentioned this pull request Mar 25, 2018
const { username } = req.auth;

// what is the type of the object we vote for (i.e. ideas, comments, ...)
const primarys = req.baseUrl.substring(1);
Copy link
Member

Choose a reason for hiding this comment

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

is there such a word?

Copy link
Member Author

@mrkvon mrkvon Mar 27, 2018

Choose a reason for hiding this comment

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

I doubt that. Do you have some alternative suggestions?
primary is supposed to mean "object to which the vote belongs" and s is supposed to mean plural of that.

Perhaps objectTypePlural, typeVotedObjects, votedCollectionsName? Any other ideas?

Copy link
Member

Choose a reason for hiding this comment

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

For me primarys can stay it doesn't make a confusion (just lingual one) and it is quite clear. I was mostly curious.

@@ -57,6 +57,9 @@ module.exports = function controllersFactory(primary) {
* Middleware to read comments of a primary object (i.e. idea)
*/
async function get(req, res, next) {

Copy link
Member

Choose a reason for hiding this comment

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

It is very nice to have this factory function for this.

return res.status(201).json(serializedVote);
} catch (e) {
// handle errors
switch (e.code) {
Copy link
Member

Choose a reason for hiding this comment

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

Are we not returning any comment for those errors? Is it because it is boring to write or somehow unnecessary with the frontend?

Copy link
Member Author

@mrkvon mrkvon Mar 27, 2018

Choose a reason for hiding this comment

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

Added error response body.

To some extent the error codes are self-explanatory. You're right that it is boring to write (and test) and that some error info would actually be useful. I'll fix it.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking more generally if there is any standard in ditup regarding this and what is the explanation.
Yes, it is quite clear what I am getting if there is 409 or 201, maybe some 400 validation explanation is useful (and that is double boring).

Copy link
Member Author

@mrkvon mrkvon Mar 27, 2018

Choose a reason for hiding this comment

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

  • we are displaying validation errors as they're generated by json-schema
  • 404 errors can be confusing (is it a nonexistent path, or user or what?) and error messages can be useful.
  • there are probably other errors with neglected but potentially useful error body reporting

}

/**
* Read a vote from user to multiple ideas or comments or something
Copy link
Member

Choose a reason for hiding this comment

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

I am curious when is it used, the function.

Copy link
Member Author

@mrkvon mrkvon Mar 27, 2018

Choose a reason for hiding this comment

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

When we want to find out whether user voted for a particular comment (to show the self vote). When there are i.e. 20 comments, we want to fetch all the user's voting info at once.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you.

Copy link
Member

@agatatalita agatatalita left a comment

Choose a reason for hiding this comment

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

Very interesting.

@mrkvon mrkvon merged commit 7c1d854 into master Mar 27, 2018
@mrkvon
Copy link
Member Author

mrkvon commented Mar 27, 2018

Thank you @agatatalita for collaborating on this. 🙂

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.

2 participants