mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
From the cpu-monster email feedback: FerretDB at 190-350% CPU on an instance with 14490 boards, of which 13404 are template containers, for 9264 accounts of which 478 have ever logged in. Before v10.00 every new account got a "Templates" container board at signup whether or not the person ever saved a template. That was made lazy in v10.00 (#2339, #5850) - `ensureTemplatesBoard` creates one only when a template is actually saved - so no NEW account creates one. But nothing ever removed the ones already made, and they are not visible enough for anybody to delete by hand. On that instance they are 13x the boards collection, and every query that touches boards carries it; under polling reactivity that is every poll. THIS DELETES BOARDS, so the rule for what may go is the whole of the risk and is deliberately narrow: only a container nobody ever used. Anything at all having been done to one keeps it - a template saved into it, a list, swimlane or card added, a second member, a rename, a star, a manual archive. The rule is in models/lib/unusedTemplateContainers.js on its own, so it can be read and tested without the method around it, and every kept board comes back with the reason it was kept. A rename is judged only against the titles the app itself used, supplied by the caller: that string is translated and has changed over time, so with no list to compare against the title is not judged at all rather than a board being deleted because its default name is in another language. And it does nothing unless asked twice. The default is a dry run reporting what WOULD go, with a sample rather than thirteen thousand rows; `apply: true` is what deletes. For a collection this size that is the difference between a cleanup and an accident. Admin only, checked before it reads anything. The `profile.templatesBoardId` pointer is cleared with the board, or the next ensureTemplatesBoard trips over a board that is not there, and one failed deletion does not abandon the rest - the ones that failed are reported. tests/unusedTemplateContainers.test.cjs is mostly about what must NOT be removed: each of the four things that can be inside one, each of the four ways a person can have claimed one, every non-container board type, junk input, and that the dry run returns before anything is deleted. Thanks to xet7 !