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
··· 591 591 } else if (endpoint === "/reset") { 592 592 groupKey = "Cache Management"; 593 593 } else { 594 - groupKey = endpoint; // Keep as-is for unknown endpoints 594 + // For any other endpoints, try to categorize them 595 + if (endpoint.includes("/users/") && endpoint.includes("/r")) { 596 + groupKey = "User Redirects"; 597 + } else if (endpoint.includes("/users/")) { 598 + groupKey = "User Data"; 599 + } else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) { 600 + groupKey = "Emoji Redirects"; 601 + } else if (endpoint.includes("/emojis/")) { 602 + groupKey = "Emoji Data"; 603 + } else { 604 + groupKey = "Other"; 605 + } 595 606 } 596 607 597 608 if (!endpointGroups[groupKey]) { ··· 1092 1103 } else if (endpoint === "/reset") { 1093 1104 groupKey = "Cache Management"; 1094 1105 } else { 1095 - groupKey = endpoint; 1106 + // For any other endpoints, try to categorize them 1107 + if (endpoint.includes("/users/") && endpoint.includes("/r")) { 1108 + groupKey = "User Redirects"; 1109 + } else if (endpoint.includes("/users/")) { 1110 + groupKey = "User Data"; 1111 + } else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) { 1112 + groupKey = "Emoji Redirects"; 1113 + } else if (endpoint.includes("/emojis/")) { 1114 + groupKey = "Emoji Data"; 1115 + } else { 1116 + groupKey = "Other"; 1117 + } 1096 1118 } 1097 1119 1098 1120 const group = timeGroups[row.time]; ··· 1169 1191 } else if (endpoint === "/reset") { 1170 1192 groupKey = "Cache Management"; 1171 1193 } else { 1172 - groupKey = endpoint; 1194 + // For any other endpoints, try to categorize them 1195 + if (endpoint.includes("/users/") && endpoint.includes("/r")) { 1196 + groupKey = "User Redirects"; 1197 + } else if (endpoint.includes("/users/")) { 1198 + groupKey = "User Data"; 1199 + } else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) { 1200 + groupKey = "Emoji Redirects"; 1201 + } else if (endpoint.includes("/emojis/")) { 1202 + groupKey = "Emoji Data"; 1203 + } else { 1204 + groupKey = "Other"; 1205 + } 1173 1206 } 1174 1207 1175 1208 intervalGroups[intervalTime][groupKey] = ··· 1236 1269 } else if (endpoint === "/reset") { 1237 1270 groupKey = "Cache Management"; 1238 1271 } else { 1239 - groupKey = endpoint; 1272 + // For any other endpoints, try to categorize them 1273 + if (endpoint.includes("/users/") && endpoint.includes("/r")) { 1274 + groupKey = "User Redirects"; 1275 + } else if (endpoint.includes("/users/")) { 1276 + groupKey = "User Data"; 1277 + } else if (endpoint.includes("/emojis/") && endpoint.includes("/r")) { 1278 + groupKey = "Emoji Redirects"; 1279 + } else if (endpoint.includes("/emojis/")) { 1280 + groupKey = "Emoji Data"; 1281 + } else { 1282 + groupKey = "Other"; 1283 + } 1240 1284 } 1241 1285 const group = dayGroups[row.time]; 1242 1286 if (group) {
+6 -11
src/dashboard.html
··· 691 691 692 692 if (charts.userAgent) charts.userAgent.destroy(); 693 693 694 - const labels = data.map((d) => { 695 - const ua = d.userAgent; 696 - if (ua.includes("Chrome")) return "Chrome"; 697 - if (ua.includes("Firefox")) return "Firefox"; 698 - if (ua.includes("Safari")) return "Safari"; 699 - if (ua.includes("curl")) return "curl"; 700 - if (ua.includes("bot")) return "Bot"; 701 - return "Other"; 702 - }); 703 - 704 694 charts.userAgent = new Chart(ctx, { 705 695 type: "pie", 706 696 data: { 707 - labels: labels, 697 + labels: data.map((d) => d.userAgent), 708 698 datasets: [ 709 699 { 710 700 data: data.map((d) => d.count), ··· 714 704 "#2ecc71", 715 705 "#f39c12", 716 706 "#9b59b6", 707 + "#34495e", 708 + "#16a085", 709 + "#8e44ad", 710 + "#d35400", 711 + "#7f8c8d", 717 712 ], 718 713 }, 719 714 ],