Scores
This commit is contained in:
125
server.js
125
server.js
@@ -188,6 +188,131 @@ app.post("/getHighest", authenticate, async (req, res) => {
|
||||
res.status(200).json({ matches: result.recordset });
|
||||
});
|
||||
|
||||
app.post("/getHighestOffense", authenticate, async (req, res) => {
|
||||
const { amount } = req.body;
|
||||
|
||||
const result = await pool.request()
|
||||
.input("amount", sql.Int, amount)
|
||||
.query(`
|
||||
SELECT TOP (@amount) 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)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END)
|
||||
|
||||
- (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)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END
|
||||
)
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear AS PaydirtScore
|
||||
|
||||
|
||||
FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract ON Player.PlayerID = Contract.PlayerID
|
||||
WHERE season = 2024 AND SeasonType = 'REG'
|
||||
GROUP BY Player.PlayerID, Player.PlayerName, Player.Team, Player.[Position], Contract.AvgPerYear
|
||||
ORDER BY OffenseScore DESC;
|
||||
`);
|
||||
|
||||
res.status(200).json({ matches: result.recordset });
|
||||
});
|
||||
app.post("/getHighestPaydirt", authenticate, async (req, res) => {
|
||||
const { amount } = req.body;
|
||||
|
||||
const result = await pool.request()
|
||||
.input("amount", sql.Int, amount)
|
||||
.query(`
|
||||
SELECT TOP (@amount) 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)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END)
|
||||
|
||||
- (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)
|
||||
- (
|
||||
CASE
|
||||
WHEN Player.Position = 'QB'
|
||||
THEN SUM(qb_dropback) - SUM(pass_attempts) - SUM(qb_scramble)
|
||||
ELSE 0
|
||||
END
|
||||
)
|
||||
- (SUM(safety) * 100.0)) / AvgPerYear AS PaydirtScore
|
||||
|
||||
|
||||
FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract ON Player.PlayerID = Contract.PlayerID
|
||||
WHERE season = 2024 AND SeasonType = 'REG'
|
||||
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("/getPlayer", authenticate, async (req, res) => {
|
||||
const { id } = req.body;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user