Scores
This commit is contained in:
@@ -39,9 +39,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box sw">
|
<div class="box sw">
|
||||||
<p>Highest paydirt score</p>
|
<p>Highest paydirt score</p>
|
||||||
|
<table class="body" id="paydirt">
|
||||||
|
<thead>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="box se">
|
<div class="box se">
|
||||||
<p>Highest offense score</p>
|
<p>Highest offense score</p>
|
||||||
|
<table class="body" id="offense">
|
||||||
|
<thead>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,94 @@ const highest = document.querySelector("#highest");
|
|||||||
|
|
||||||
updateHighest();
|
updateHighest();
|
||||||
updateFavorites();
|
updateFavorites();
|
||||||
|
updatePaydirt();
|
||||||
|
updateOffense();
|
||||||
|
|
||||||
|
async function updateOffense() {
|
||||||
|
if (!verifyLogin()) return;
|
||||||
|
|
||||||
|
|
||||||
|
const offenseHeader = document.querySelector("#offense thead");
|
||||||
|
const offenseBody = document.querySelector("#offense tbody");
|
||||||
|
|
||||||
|
|
||||||
|
let resultObject = await postData("/getHighestOffense", { amount: 10 }, token);
|
||||||
|
console.log(resultObject);
|
||||||
|
|
||||||
|
if (resultObject.matches.length === 0) {
|
||||||
|
alert("Error loading scores");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
offenseHeader.innerHTML = "";
|
||||||
|
const headerRow = document.createElement("tr");
|
||||||
|
//Object.keys(resultObject.matches[0]).forEach(attribute => {
|
||||||
|
// headerRow.innerHTML += `<td>${attribute}</td>`;
|
||||||
|
//});
|
||||||
|
headerRow.innerHTML = `
|
||||||
|
<td>Position</td>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Team</td>
|
||||||
|
<td>Offense Score</td>
|
||||||
|
`;
|
||||||
|
offenseHeader.appendChild(headerRow);
|
||||||
|
|
||||||
|
offenseBody.innerHTML = "";
|
||||||
|
resultObject.matches.forEach(player => {
|
||||||
|
const row = document.createElement("tr");
|
||||||
|
|
||||||
|
row.innerHTML = `
|
||||||
|
<td>${player.Position}</td>
|
||||||
|
<td><a href="/player/${player.PlayerID}">${player.PlayerName}</a></td>
|
||||||
|
<td>${player.Team}</td>
|
||||||
|
<td>${(player.OffenseScore + "000000").slice(0, 8)}</td>
|
||||||
|
`;
|
||||||
|
offenseBody.appendChild(row);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
async function updatePaydirt() {
|
||||||
|
if (!verifyLogin()) return;
|
||||||
|
|
||||||
|
|
||||||
|
const paydirtHeader = document.querySelector("#paydirt thead");
|
||||||
|
const paydirtBody = document.querySelector("#paydirt tbody");
|
||||||
|
|
||||||
|
|
||||||
|
let resultObject = await postData("/getHighestPaydirt", { amount: 10 }, token);
|
||||||
|
console.log(resultObject);
|
||||||
|
|
||||||
|
if (resultObject.matches.length === 0) {
|
||||||
|
alert("Error loading scores");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
paydirtHeader.innerHTML = "";
|
||||||
|
const headerRow = document.createElement("tr");
|
||||||
|
//Object.keys(resultObject.matches[0]).forEach(attribute => {
|
||||||
|
// headerRow.innerHTML += `<td>${attribute}</td>`;
|
||||||
|
//});
|
||||||
|
headerRow.innerHTML = `
|
||||||
|
<td>Position</td>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Team</td>
|
||||||
|
<td>Paydirt Score</td>
|
||||||
|
`;
|
||||||
|
paydirtHeader.appendChild(headerRow);
|
||||||
|
|
||||||
|
paydirtBody.innerHTML = "";
|
||||||
|
resultObject.matches.forEach(player => {
|
||||||
|
const row = document.createElement("tr");
|
||||||
|
|
||||||
|
row.innerHTML = `
|
||||||
|
<td>${player.Position}</td>
|
||||||
|
<td><a href="/player/${player.PlayerID}">${player.PlayerName}</a></td>
|
||||||
|
<td>${player.Team}</td>
|
||||||
|
<td>${(player.PaydirtScore + "000000").slice(0, 8)}</td>
|
||||||
|
`;
|
||||||
|
paydirtBody.appendChild(row);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
async function updateHighest() {
|
async function updateHighest() {
|
||||||
if (!verifyLogin()) return;
|
if (!verifyLogin()) return;
|
||||||
|
|||||||
125
server.js
125
server.js
@@ -188,6 +188,131 @@ app.post("/getHighest", authenticate, async (req, res) => {
|
|||||||
res.status(200).json({ matches: result.recordset });
|
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) => {
|
app.post("/getPlayer", authenticate, async (req, res) => {
|
||||||
const { id } = req.body;
|
const { id } = req.body;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user