-
Notifications
You must be signed in to change notification settings - Fork 1
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
Create rating api #30
Conversation
backend/controllers/rate.js
Outdated
@@ -0,0 +1,22 @@ | |||
// Load required packages | |||
var Rate = require('../models/history.js'); |
There was a problem hiding this comment.
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
backend/controllers/rate.js
Outdated
// 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!'}); |
There was a problem hiding this comment.
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
backend/controllers/rate.js
Outdated
// 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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
backend/controllers/rate.js
Outdated
rate.updateAttributes({ | ||
score: score | ||
}).then(function () { | ||
return res.json({status: 'success', message: 'Ratings Updated'}); |
There was a problem hiding this comment.
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
Updated |
Issue #8 #9 #10
Currently not supporting deletion of ratings