BL star endpoint actually gets cached???

This commit is contained in:
Liam 2022-10-20 18:36:26 +01:00
parent 253cd4a103
commit 14602dc11a
2 changed files with 9 additions and 9 deletions

@ -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",

@ -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 (
<div className={styles.scoreStats}>