Player
This commit is contained in:
104
server.js
104
server.js
@@ -218,11 +218,7 @@ SUM(total_yards)
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END)
|
||||
SUM(tackled_for_loss))
|
||||
|
||||
- (SUM(safety) * 100.0)
|
||||
AS OffenseScore,
|
||||
@@ -233,11 +229,7 @@ AvgPerYear,
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END
|
||||
SUM(tackled_for_loss)
|
||||
)
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear AS PaydirtScore
|
||||
|
||||
@@ -250,6 +242,81 @@ ORDER BY OffenseScore DESC;
|
||||
|
||||
res.status(200).json({ matches: result.recordset });
|
||||
});
|
||||
|
||||
|
||||
app.post("/getPlayerStats", authenticate, async (req, res) => {
|
||||
const { playerID } = req.body;
|
||||
|
||||
const result = await pool.request()
|
||||
.input("playerID", sql.Int, playerID)
|
||||
.query(`
|
||||
SELECT Player.PlayerID, Player.PlayerName, Season, SeasonType, Week, pass_attempts, complete_pass, total_yards, total_tds, interception, receptions, receiving_yards, receiving_touchdown, rush_attempts, rushing_yards, rush_touchdown, fumble
|
||||
FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID
|
||||
WHERE Player.PlayerID = @playerID
|
||||
ORDER BY Season, week;
|
||||
`);
|
||||
|
||||
res.status(200).json({ matches: result.recordset });
|
||||
});
|
||||
|
||||
app.post("/getPlayerScores", authenticate, async (req, res) => {
|
||||
const { playerID } = req.body;
|
||||
|
||||
const result = await pool.request()
|
||||
.input("playerID", sql.Int, playerID)
|
||||
.query(`
|
||||
SELECT Player.PlayerID, Player.[Position], Player.PlayerName, Player.Team,
|
||||
SUM(total_yards) AS TotalYards,
|
||||
SUM(passing_yards) AS PassingYards,
|
||||
SUM(rushing_yards) AS RushingYards,
|
||||
SUM(receiving_yards) AS RecievingYards,
|
||||
CASE WHEN Player.Position = 'QB' THEN (SUM(pass_touchdown)) ELSE 0 END + SUM(receiving_touchdown) + SUM(rush_touchdown) AS AmendedTotalTDs,
|
||||
CASE WHEN Player.Position = 'QB' THEN (SUM(pass_touchdown)) ELSE 0 END AS PassTDs,
|
||||
SUM(receiving_touchdown) AS ReceivingTDs,
|
||||
SUM(rush_touchdown) AS RushTDs,
|
||||
SUM(offense_snaps) * 1.0 / SUM(team_offense_snaps) AS SnapPercentage,
|
||||
SUM(interception) + sum(fumble_lost) AS Turnovers,
|
||||
SUM(tackled_for_loss) AS TackledForLoss,
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END AS Sacks,
|
||||
SUM(safety) AS Safties,
|
||||
|
||||
SUM(total_yards)
|
||||
+ ((CASE WHEN Player.Position = 'QB' THEN (SUM(pass_touchdown)) ELSE 0 END + SUM(receiving_touchdown) + SUM(rush_touchdown)) * 50)
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
SUM(tackled_for_loss)
|
||||
)
|
||||
|
||||
- (SUM(safety) * 100.0)
|
||||
AS OffenseScore,
|
||||
|
||||
AvgPerYear,
|
||||
(SUM(total_yards)
|
||||
+ ((CASE WHEN Player.Position = 'QB' THEN (SUM(pass_touchdown)) ELSE 0 END + SUM(receiving_touchdown) + SUM(rush_touchdown)) * 50)
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
SUM(tackled_for_loss)
|
||||
)
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear * 1000000 AS PaydirtScore
|
||||
|
||||
|
||||
FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract ON Player.PlayerID = Contract.PlayerID
|
||||
WHERE season = 2024 AND SeasonType = 'REG' AND Player.PlayerID = @playerID
|
||||
GROUP BY Player.PlayerID, Player.PlayerName, Player.Team, Player.[Position], Contract.AvgPerYear
|
||||
ORDER BY PaydirtScore DESC;
|
||||
`);
|
||||
|
||||
res.status(200).json({ matches: result.recordset });
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post("/getHighestPaydirt", authenticate, async (req, res) => {
|
||||
const { amount } = req.body;
|
||||
|
||||
@@ -280,11 +347,7 @@ SUM(total_yards)
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END)
|
||||
SUM(tackled_for_loss))
|
||||
|
||||
- (SUM(safety) * 100.0)
|
||||
AS OffenseScore,
|
||||
@@ -295,13 +358,10 @@ AvgPerYear,
|
||||
+ (SUM(offense_snaps) * 100.0 / SUM(team_offense_snaps))
|
||||
- ((SUM(interception) + sum(fumble_lost)) * 75)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END
|
||||
SUM(tackled_for_loss)
|
||||
)
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear AS PaydirtScore
|
||||
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear * 1000000 AS PaydirtScore
|
||||
|
||||
|
||||
FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract ON Player.PlayerID = Contract.PlayerID
|
||||
@@ -318,7 +378,7 @@ app.post("/getPlayer", authenticate, async (req, res) => {
|
||||
|
||||
const result = await pool.request()
|
||||
.input("query", sql.VarChar, id)
|
||||
.query(`SELECT p.PlayerName, p.PlayerID, c.TotalValue, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerID = @query`);
|
||||
.query(`SELECT p.PlayerName, p.PlayerID, c.TotalValue, c.TrueAvgPerYear, c.Years, c.StartYear, c.EndYear, p.Team, p.Position, p.Height, p.Weight FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerID = @query`);
|
||||
|
||||
if (result.recordset.length !== 1) {
|
||||
res.status(400).json({ success: false })
|
||||
|
||||
Reference in New Issue
Block a user