[MGNLUI-3936] Newly created messages are not be stored in proper date folder Created: 05/Jul/16  Updated: 18/Aug/21

Status: Accepted
Project: Magnolia UI
Component/s: messages app
Affects Version/s: 6.2.11
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Richard Gange Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: maintenance, support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File messages.png    
Issue Links:
duplicate
duplicates TASKMGMT-22 Newly created tasks may not be stored... Closed
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)

 Description   

Currently messages are organized in the messages workspace by username. So each username has an entry in the workspace. Under the username node there can be several message nodes all organized at the same level (see messages.png attached). This creates a performance problem when a user accumulates too many messages under a single username node.

This issue is similar to one we had with tasks (see TASKMGMT-22).

Workaround
Use a script

import info.magnolia.context.MgnlContext;
import javax.jcr.Session;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
 
def removeMessages(username) {
    try {
        Session session = MgnlContext.getJCRSession("messages");
        path = "/" + username;
        Node usertree = session.getNode(path);
        NodeIterator childrenIterator = usertree.getNodes();
 
        while (childrenIterator.hasNext()) {
            Node node = childrenIterator.nextNode();
            path = node.getPath();
            println "about to remove ${path} item";
            session.removeItem(path);             
        }
        session.save();
        println "messages of ${username} removed";
 
    } catch (Exception e) {
        println e;
    }
}
 
//example of usage
removeMessages("superuser");

Generated at Mon Feb 12 09:11:37 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.