diff --git a/pages/api/beatleader/stars.js b/pages/api/beatleader/stars.js index 34b9d12..5ae4b5c 100644 --- a/pages/api/beatleader/stars.js +++ b/pages/api/beatleader/stars.js @@ -15,11 +15,10 @@ export default async function handler(req, res) { const difficulty = req.query.difficulty.replace(" ", ""); const characteristic = req.query.characteristic; - const exists = await RedisUtils.exists(`${KEY}${mapHash}`); + const key = `${KEY}${difficulty}-${characteristic}-${mapHash}`; + const exists = await RedisUtils.exists(key); if (exists) { - const data = await RedisUtils.getValue( - `${KEY}${difficulty}-${characteristic}-${mapHash}`.replace(" ", "") - ); + const data = await RedisUtils.getValue(key); res.setHeader("Cache-Status", "hit"); return res.status(200).json({ @@ -46,10 +45,7 @@ export default async function handler(req, res) { }); } const json = await data.json(); - RedisUtils.setValue( - `${KEY}${difficulty}-${characteristic}-${mapHash}`.replace(" ", ""), - json.difficulty.stars - ); + RedisUtils.setValue(key, json.difficulty.stars); res.setHeader("Cache-Status", "miss"); return res.status(200).json({ status: "OK", diff --git a/src/components/ScoreStats.js b/src/components/ScoreStats.js index e025688..77628a6 100644 --- a/src/components/ScoreStats.js +++ b/src/components/ScoreStats.js @@ -26,9 +26,13 @@ export default class ScoreStats extends Component { data.percentage.replace("%", ""), data.websiteType ); - if (this.lastKnownPP === undefined || this.lastKnownPP < currentPP) { + if (this.lastKnownPP === undefined) { + this.lastKnownPP = currentPP; + } + if (currentPP < this.lastKnownPP || currentPP === undefined) { currentPP = this.lastKnownPP; } + this.lastKnownPP = currentPP; return (