Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const asyncHandler = require('../middleware/asyncHandler')
- const { assignedproject, features, project, scenarios } = require('../src/models')
- exports.getTesterStatistic = asyncHandler(async (req, res, next) => {
- const testerId = req.user.id
- const totalAssigned = await assignedproject.findAndCountAll({
- where: {
- userId: testerId
- },
- attributes: ['projectId']
- })
- const projectId = totalAssigned.rows.map(row => row.projectId)
- const projectTested = await project
- .findAll({
- where: {
- id: projectId,
- status: 'TESTED'
- },
- attributes: ['id']
- })
- .map(project => project.id)
- const totalFeature = await features.findAndCountAll({
- where: {
- projectId: projectTested
- },
- attributes: ['id']
- })
- const featureId = totalFeature.rows.map(row => row.id)
- const totalScenarios = await scenarios.count({
- where: {
- id: featureId
- }
- })
- res.jsend.success({
- totalProjects: totalAssigned.count,
- totalFeatures: totalFeature.count,
- totalScenarios: totalScenarios
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement