X-Git-Url: http://repos.xcallymotion.com/?a=blobdiff_plain;f=server%2Fmodels%2Freport_jscripty_question.js;h=127f733e786acd849fcb93561d08c37aee484f1e;hb=903634fc494ad4b4cbb03bbae15556481571adc6;hp=5affcb1db36f23be429377dc2ab52af876eba851;hpb=a7a17608f349df2adb5d19117e2f6b46ae156852;p=motion.git diff --git a/server/models/report_jscripty_question.js b/server/models/report_jscripty_question.js index 5affcb1..127f733 100644 --- a/server/models/report_jscripty_question.js +++ b/server/models/report_jscripty_question.js @@ -9,8 +9,8 @@ module.exports = function(sequelize, DataTypes) { question_answer: DataTypes.STRING, question_other_label: DataTypes.STRING, question_other_answer: DataTypes.STRING, - question_options: DataTypes.STRING - + question_options: DataTypes.STRING, + index: DataTypes.INTEGER }, { tableName: 'report_jscripty_questions', associate: function(models) { @@ -19,16 +19,20 @@ module.exports = function(sequelize, DataTypes) { foreignKey: 'questionId' }); - // models.ReportJscriptyQuestion.addScope('questionSummary', function(projectId) { - // return { - // where: { - // projectId: projectId - // }, - // attributes: ['question_id', 'question_type', 'question_label', 'question_text', [sequelize.fn('count', sequelize.col('question_id')), 'count']], - // group: ['question_id', 'question_type', 'question_label', 'question_text'] - // } - // - // }); + models.ReportJscriptyQuestion.addScope('otherOption', function(projectId, questionId) { + return { + where: { + ProjectId: projectId, + question_id: questionId, + question_type: 'question', + question_other_answer: { + $ne: null + } + }, + attributes: ['question_type', 'question_id', 'question_label', 'question_text', 'question_other_label', 'question_other_answer'], + } + + }); models.ReportJscriptyQuestion.addScope('summary', function(projectId) { return { where: {