AnsweredAssumed Answered

How get first children with FTL

Question asked by spilby on Aug 14, 2015
Latest reply on Aug 14, 2015 by muralidharand
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" : "${}",
         "PROP_NAME" : "${["name"]}",
            "AUTHOR" : "${["cf:author"]}",
            "PROP_CREATED" : "${xmldate(["cf:date_cf"]?datetime)}",
         "TYPE" : "${child.type}",
              "NUMBER_CHILDS" : ${child.children?size}

      <#assign loop = loop + 1 />

<#if (childResults?size > 0)>
   "nodes" :
      <@parseChild childResults/>

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!