Skip to content

Commit

Permalink
fixing rank NAs
Browse files Browse the repository at this point in the history
  • Loading branch information
akeaswaran committed Sep 11, 2024
1 parent 2675df9 commit dc7c94c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
8 changes: 7 additions & 1 deletion frontend/cfb/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ async function retrievePercentiles(year) {
}

async function retrieveRemoteData(payload) {
console.log(`loading from summary: ${JSON.stringify(payload)}`)
const response = await axios({
method: 'POST',
url: `http://summary:3000/`,
Expand Down Expand Up @@ -193,7 +194,6 @@ async function retrieveRemoteTeamData(year, abbreviation, type) {
team: abbreviation,
type: type
});
// console.log(content)
const key = `${year}-${abbreviation}-${type}`;
await redisClient.set(key, JSON.stringify(content))
await redisClient.expire(key, 60 * 60 * 24 * 3); // expire every three days so that we get fresh data
Expand Down Expand Up @@ -323,6 +323,12 @@ function cleanAbbreviation(abbrev) {
if (abbrev == 'NU') {
return 'NW'
}
if (abbrev == 'NCSU') {
return 'NCST'
}
if (abbrev == "MASS") {
return "UMASS"
}
if (abbrev == 'CLT') {
return 'CHAR'
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/views/pages/cfb/leaderboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ function roundNumber(value, power10, fixed) {
}
function cleanRank(rank) {
let tied = rank?.includes(".5")
if (rank == null || (!rank && rank != 0)) {
return "N/A"
}
let tied = String(rank)?.includes(".5")
let rankString = ""
if (rank && tied) {
rankString = `T-${roundNumber(Math.floor(parseFloat(rank)), 2, 0)}`;
Expand Down
2 changes: 1 addition & 1 deletion frontend/views/pages/cfb/player_leaderboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function cleanRank(rank) {
if (rank == null || (!rank && rank != 0)) {
return "N/A"
}
<!-- console.log(`rank: ${rank}`) -->
let tied = String(rank)?.includes(".5")
let rankString = ""
if (rank && tied) {
Expand Down
6 changes: 5 additions & 1 deletion frontend/views/partials/matchup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
}
function produceRankHtml(rank, addClass = "", addStyle = "") {
let tied = rank?.includes(".5")
if (rank == null || (!rank && rank != 0)) {
return "N/A"
}
let tied = String(rank)?.includes(".5")
let rankString = ""
if (rank && tied) {
rankString = `T-#${roundNumber(Math.floor(parseFloat(rank)), 2, 0)}`;
Expand Down
5 changes: 3 additions & 2 deletions frontend/views/partials/team_slice.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
colorClass = generateColorRampValue(rank, 130, null, 255)
}
let tied = rank?.includes(".5")
let rankString = ""
if (rank && tied) {
if (rank == null || (!rank && rank != 0)) {
rankString = ``; // don't show text
} else if (rank && (String(rank)?.includes(".5") ?? false)) {
rankString = ` <small class="align-self-center" style="opacity: 50%"> T-#${roundNumber(Math.floor(parseFloat(rank)), 2, 0)}</small>`;
} else if (rank) {
rankString = ` <small class="align-self-center" style="opacity: 50%"> #${roundNumber(Math.floor(parseFloat(rank)), 2, 0)}</small>`
Expand Down

0 comments on commit dc7c94c

Please sign in to comment.