sort icons by how much they are used, #3784

This commit is contained in:
zadam
2023-03-29 22:40:50 +02:00
parent 2d7b5e4aa2
commit d354c91d7c
4 changed files with 79 additions and 20 deletions

29
src/routes/api/other.js Normal file
View File

@@ -0,0 +1,29 @@
const becca = require("../../becca/becca");
function getIconUsage() {
const iconClassToCountMap = {};
for (const {value: iconClass, noteId} of becca.findAttributes('label', 'iconClass')) {
if (noteId.startsWith("_")) {
continue; // ignore icons of "system" notes since they were not set by the user
}
if (!iconClass?.trim()) {
continue;
}
for (const clazz of iconClass.trim().split(/\s+/)) {
if (clazz === 'bx') {
continue;
}
iconClassToCountMap[clazz] = (iconClassToCountMap[clazz] || 0) + 1;
}
}
return { iconClassToCountMap };
}
module.exports = {
getIconUsage
};