Skip to content

Commit

Permalink
Include parent task in counts
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jul 5, 2023
1 parent 3000f83 commit 116518e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion metriq-api/service/taskService.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ class TaskService extends ModelService {

async getNamesAndCounts (parentId, userId) {
const parentTask = (await sequelize.query(
'SELECT id, name, description FROM tasks WHERE tasks.id = ' + parentId + ';'
'SELECT id, name, description, "taskId" FROM tasks WHERE tasks.id = ' + parentId + ';'
))[0][0]
parentTask.submissionCount = await this.getParentSubmissionCount(parentId)
parentTask.upvoteTotal = await this.getParentLikeCount(parentId)
parentTask.resultCount = await this.getParentResultCount(parentId)
if (userId) {
parentTask.isSubscribed = !!(await taskSubscriptionService.getByFks(userId, parentTask.id))
}
parentTask.parentTask = await this.getByPk(parentTask.taskId)
parentTask.taskId = undefined
return { success: true, body: parentTask }
}

Expand Down

0 comments on commit 116518e

Please sign in to comment.