a cache for slack profile pictures and emojis

chore: group endpoints

dunkirk.sh 7c4eb984 307ce9c2

verified
Changed files
+54 -15
src
+48 -4
src/cache.ts
···
} else if (endpoint === "/reset") {
groupKey = "Cache Management";
} else {
-
groupKey = endpoint; // Keep as-is for unknown endpoints
+
// For any other endpoints, try to categorize them
+
if (endpoint.includes("/users/") && endpoint.includes("/r")) {
+
groupKey = "User Redirects";
+
} else if (endpoint.includes("/users/")) {
+
groupKey = "User Data";
+
} else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) {
+
groupKey = "Emoji Redirects";
+
} else if (endpoint.includes("/emojis/")) {
+
groupKey = "Emoji Data";
+
} else {
+
groupKey = "Other";
+
}
}
if (!endpointGroups[groupKey]) {
···
} else if (endpoint === "/reset") {
groupKey = "Cache Management";
} else {
-
groupKey = endpoint;
+
// For any other endpoints, try to categorize them
+
if (endpoint.includes("/users/") && endpoint.includes("/r")) {
+
groupKey = "User Redirects";
+
} else if (endpoint.includes("/users/")) {
+
groupKey = "User Data";
+
} else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) {
+
groupKey = "Emoji Redirects";
+
} else if (endpoint.includes("/emojis/")) {
+
groupKey = "Emoji Data";
+
} else {
+
groupKey = "Other";
+
}
const group = timeGroups[row.time];
···
} else if (endpoint === "/reset") {
groupKey = "Cache Management";
} else {
-
groupKey = endpoint;
+
// For any other endpoints, try to categorize them
+
if (endpoint.includes("/users/") && endpoint.includes("/r")) {
+
groupKey = "User Redirects";
+
} else if (endpoint.includes("/users/")) {
+
groupKey = "User Data";
+
} else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) {
+
groupKey = "Emoji Redirects";
+
} else if (endpoint.includes("/emojis/")) {
+
groupKey = "Emoji Data";
+
} else {
+
groupKey = "Other";
+
}
intervalGroups[intervalTime][groupKey] =
···
} else if (endpoint === "/reset") {
groupKey = "Cache Management";
} else {
-
groupKey = endpoint;
+
// For any other endpoints, try to categorize them
+
if (endpoint.includes("/users/") && endpoint.includes("/r")) {
+
groupKey = "User Redirects";
+
} else if (endpoint.includes("/users/")) {
+
groupKey = "User Data";
+
} else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) {
+
groupKey = "Emoji Redirects";
+
} else if (endpoint.includes("/emojis/")) {
+
groupKey = "Emoji Data";
+
} else {
+
groupKey = "Other";
+
}
const group = dayGroups[row.time];
if (group) {
+6 -11
src/dashboard.html
···
if (charts.userAgent) charts.userAgent.destroy();
-
const labels = data.map((d) => {
-
const ua = d.userAgent;
-
if (ua.includes("Chrome")) return "Chrome";
-
if (ua.includes("Firefox")) return "Firefox";
-
if (ua.includes("Safari")) return "Safari";
-
if (ua.includes("curl")) return "curl";
-
if (ua.includes("bot")) return "Bot";
-
return "Other";
-
});
-
charts.userAgent = new Chart(ctx, {
type: "pie",
data: {
-
labels: labels,
+
labels: data.map((d) => d.userAgent),
datasets: [
{
data: data.map((d) => d.count),
···
"#2ecc71",
"#f39c12",
"#9b59b6",
+
"#34495e",
+
"#16a085",
+
"#8e44ad",
+
"#d35400",
+
"#7f8c8d",
],
},
],