Skip to content

Commit

Permalink
last touches
Browse files Browse the repository at this point in the history
  • Loading branch information
eferhatg committed Apr 29, 2016
1 parent 9622d4a commit 7961faa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion controllers/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ QuestionController.prototype.all = function(request, reply) {
// [GET] /tasks/{id}
QuestionController.prototype.userquestions = function(request, reply) {

this.questionModel.userquestions(request.query.user_id, request.query.limit,function(data) {
this.questionModel.userquestions(request.params.app, request.query.user_id, request.query.limit,function(data) {
reply({
data: {
"count": data.length,
Expand Down
12 changes: 6 additions & 6 deletions models/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ QuestionModel.prototype.showAllQuestions = function(cb) {
this.questionSchema.findAll().then(function(questions) {
cb(questions);
});

};

QuestionModel.prototype.userQuestions = function(user_id,limit,cb) {
QuestionModel.prototype.userQuestions = function(app, user_id, limit, cb) {

this.questionSchema.findAll({
where: { user_id: user_id },
limit:limit,
is_deleted:false
where: { user_id: user_id, app: app },
limit: limit,
is_deleted: false
}).then(function(questions) {
cb(questions);
});

};

QuestionModel.prototype.fetchQuestions = function(app, limit, user_id, installation_id, cb) {
Expand Down
9 changes: 4 additions & 5 deletions routes/v1/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ exports.register = function(server, options, next) {
notes: ['user sorularını çeker'
],

handler: questionController.addQuestion,
handler: questionController.userQuestion,
validate: {
payload: Joi.object().keys({
user_id: Joi.string().required().description('User id'),
payload: Joi.object().keys({
app: Joi.number().min(0).max(1).required().description('App referandum için 0, kapistir için 1'),
option_a: Joi.when('app', { is: 1, then: Joi.required() }).description('A şıkkı metni ya da resim linki'),
option_b: Joi.when('app', { is: 1, then: Joi.required() }).description('B şıkkı metni ya da resim linki'),
limit:Joi.number().description('Kaç adet soru getireceği bilgisi, default: 10'),
user_id:Joi.string().description('Kaç adet soru getireceği bilgisi, default: 10'),
}),
headers: Joi.object({
'x-voter-client-id': Joi.string().required().description('Her app için farklı olacak.'),
Expand Down

0 comments on commit 7961faa

Please sign in to comment.