MCPcopy Create free account
hub / github.com/CFBD/cfb-api / getPPAByPlayerGame

Function getPPAByPlayerGame

app/ppa/ppa.controller.js:102–138  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

100 };
101
102 const getPPAByPlayerGame = async (req, res) => {
103 try {
104 if (!req.query.week && !req.query.team) {
105 res.status(400).send({
106 error: 'A week or team must be specified'
107 });
108 } else if (req.query.year && !parseInt(req.query.year)) {
109 res.status(400).send({
110 error: 'year must be numeric'
111 });
112 } else if (req.query.week && !parseInt(req.query.week)) {
113 res.status(400).send({
114 error: 'week must be numeric'
115 });
116 } else if (req.query.threshold && !parseInt(req.query.threshold)) {
117 res.status(400).send({
118 error: 'threshold must by numeric'
119 });
120 } else if (req.query.playerId && !parseInt(req.query.playerId)) {
121 res.status(400).send({
122 error: 'playerId must be numeric'
123 });
124 } else if (req.query.seasonType && req.query.seasonType != 'regular' && req.query.seasonType != 'postseason' && req.query.seasonType != 'both') {
125 res.status(400).send({
126 error: 'Invalid season type'
127 });
128 } else {
129 const results = await service.getPPAByPlayerGame(req.query.year, req.query.week, req.query.position, req.query.team, req.query.playerId, req.query.threshold, req.query.excludeGarbageTime, req.query.seasonType);
130 res.send(results);
131 }
132 } catch (err) {
133 Sentry.captureException(err);
134 res.status(500).send({
135 error: 'Something went wrong.'
136 });
137 }
138 };
139
140 const getPPAByPlayerSeason = async (req, res) => {
141 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected