I have a performance time problem with a custom webscript that I'm doing.The webscript only search a node by uuid and return a JSON with some properties of the children of this node, and return the number of the subchilds of them too.I do this in my js:
function main()
{
var node = [];
node = search.findNode("workspace://SpacesStore/"+args["uuid"]);
model.childResults = node.children;
} main();
And on my FTL I do this:
<#macro parseChild objectModel>
<#assign loop = 0 />
<#list objectModel as child>
<#if (loop > 0) >, </#if>
{
"ID" : "${child.id}",
"PROP_NAME" : "${child.properties["name"]}",
<#if child.properties["cf:author"]?exists>
"AUTHOR" : "${child.properties["cf:author"]}",
</#if>
<#if child.properties["cf:data_cf"]?exists>
"PROP_CREATED" : "${xmldate(child.properties["cf:date_cf"]?datetime)}",
</#if>
"TYPE" : "${child.type}",
"NUMBER_CHILDS" : ${child.children?size}
<#assign loop = loop + 1 />
}
</#list>
</#macro>
<#if (childResults?size > 0)>
{
"nodes" :
[
<@parseChild childResults/>
]
}
<#else>
Empty
</#if>
The problem is… I have over 200 folders on the node, and each one have 30 or 40 subfolders too. And when I do child.children?size the webscript takes a lot of time. Are there any quickly way to know the number of childs on this 200 folders? child.children takes too long.If this methos don't exists, I have another possibility. Returns only a parameter that gives me if each of this 200 folders have at least one children. For this, I only need to obtain a children of each one. How can I do this? What method can I apply to each child to obtain the first child or know if this child have a child?Thank you very much!