added bullpen summary route and controller
This commit is contained in:
parent
ea80c8b95d
commit
37218e672e
|
|
@ -83,3 +83,29 @@ exports.findOne = (req, res) => {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.summaryForPlayer = (req, res) => {
|
||||
const { user } = req.query;
|
||||
const condition = user ? { pitcherId: { [Op.eq]: parseInt(user, 10) } } : null;
|
||||
|
||||
BullpenSession.findAll({
|
||||
where: condition,
|
||||
include: {
|
||||
model: Pitch,
|
||||
as: 'pitches'
|
||||
}
|
||||
}).then(data => {
|
||||
const summary = {
|
||||
pitchCount: 0,
|
||||
precisionRate: 0,
|
||||
strikeRate: 0,
|
||||
ballRate: 0,
|
||||
since: new Date()
|
||||
};
|
||||
|
||||
}).catch(err => {
|
||||
res.status(500).send({
|
||||
message: `Error retrieving bullpens for user with id=${user}: ${err.message}`
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,8 @@ module.exports = function(app) {
|
|||
"/api/bullpen_session/:id",
|
||||
[authJwt.verifyToken],
|
||||
controller.findOne);
|
||||
app.get(
|
||||
"/api/bullpen_session/summary",
|
||||
[authJwt.verifyToken],
|
||||
controller.summaryForPlayer);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue