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

Create rating api #30

Merged

Conversation

zzzzwen
Copy link
Contributor

@zzzzwen zzzzwen commented Feb 6, 2017

Issue #8 #9 #10

Currently not supporting deletion of ratings

@@ -0,0 +1,22 @@
// Load required packages
var Rate = require('../models/history.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

line 2: variable naming convention should be lowerCamelCase

// Save the rating and check for errors
Rate.build({score: score, movie_id: movieId, user_id: userId})
.save().then(function (success) {
res.json({message: 'Ratings successfully posted!'});
Copy link
Contributor

@Shadowsong27 Shadowsong27 Feb 12, 2017

Choose a reason for hiding this comment

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

line 12: JSON format, I think break lines around curly brackets should be used, even though it is just one line json

// Create endpoint /api/ratings for GET
exports.getRates = function (req, res) {
// Use the Ratings model to find all clients
Rate.findAll({where: {user_id: req.user.id}}).then(function(ratings){
Copy link
Contributor

@Shadowsong27 Shadowsong27 Feb 12, 2017

Choose a reason for hiding this comment

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

same as above

@zzzzwen zzzzwen added this to the V0.2 milestone Feb 12, 2017
rate.updateAttributes({
score: score
}).then(function () {
return res.json({status: 'success', message: 'Ratings Updated'});
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalised every first letter in message may not be needed

@zzzzwen
Copy link
Contributor Author

zzzzwen commented Feb 14, 2017

Updated

@Shadowsong27 Shadowsong27 merged commit a2ea7fe into development-backend Feb 17, 2017
@zzzzwen zzzzwen deleted the development-backend-8-rate-movie-api branch February 19, 2017 04:59
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.

2 participants