total-questions added to the attributes#15
Open
Manit1 wants to merge 3 commits intocoding-blocks:masterfrom
Open
total-questions added to the attributes#15Manit1 wants to merge 3 commits intocoding-blocks:masterfrom
Manit1 wants to merge 3 commits intocoding-blocks:masterfrom
Conversation
Contributor
Author
|
@abhishek97 |
Contributor
|
This would not work if i don't include all questions along with quiz. Ideally this should at controller level |
Contributor
Author
|
@abhishek97 sure ! const {rows, count} = this.findAll(...arguments)
rows = rows.map( _ => _.get({plain: true}))
rows.map(async row => {
const res = await QuizQuestions.find({
attributes: [Sequelize.fn('count', Sequelize.col('id')), 'questions'],
where: {
quizId: row.id
}
})
row['total-questions'] = res.questions
}) |
Contributor
|
Can be done for and then map total to the quizzes object |
Contributor
Author
|
@abhishek97 Thanks and done! 😄 🚀 |
abhishek97
reviewed
Aug 5, 2019
| const controller = new BaseController(DB.quizzes) | ||
|
|
||
| routes.use(passport.authenticate('bearer', {session: false}), adminOnly) | ||
| // routes.use(passport.authenticate('bearer', {session: false}), adminOnly) |
Contributor
There was a problem hiding this comment.
This isn't mean to be like this
abhishek97
reviewed
Aug 5, 2019
| group: ['quizzes.id'] | ||
| }) | ||
| quizQuestionCounts = R.groupBy(obj => obj.id)(quizQuestionCounts) | ||
| rows = rows.map( _ => _.get({plain: true})) |
Contributor
There was a problem hiding this comment.
these those map calls can be combined into one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13