fix: Refines mood domain handling in heatmap

Converts mood domain keys to numbers for uniform processing.
Removes console logs for cleaner production code.
This commit is contained in:
Kumi 2024-11-28 15:19:46 +01:00
parent 2f1cdd2de1
commit 2c4e02e1af
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -8,13 +8,10 @@ fetch("/mood/statistics/heatmap/values/")
const start = new Date(new Date().setFullYear(new Date().getFullYear() - 1)); const start = new Date(new Date().setFullYear(new Date().getFullYear() - 1));
const end = new Date(); const end = new Date();
var domain = Object.keys(moodOptions); var domain = Object.keys(moodOptions).map((key) => Number(key));
const range = ["#ffffd4"].concat(domain.map((key) => moodOptions[key]["color"])).concat(["#000000"]); const range = ["#ffffd4"].concat(domain.map((key) => moodOptions[key]["color"])).concat(["#000000"]);
domain = [0].concat(domain).concat([Infinity]); domain = [0].concat(domain).concat([Infinity]);
console.log(domain);
console.log(range);
fetch("/mood/statistics/heatmap/?start=" + start.toISOString().split("T")[0] + "&end=" + end.toISOString().split("T")[0]) fetch("/mood/statistics/heatmap/?start=" + start.toISOString().split("T")[0] + "&end=" + end.toISOString().split("T")[0])
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {