Skip to content

Let 'javascript' handle aggregation! #87

@jf-tech

Description

@jf-tech

The current way of doing sum/avg feels awkward and clumsy. Since we have 'javascript' custom_func, let it handle aggregation. The idea is to have its argument decl support array:

from:

 "total_price": { "custom_func": { "name": "javascript", "args": [ { "const": "num * price" }, { "const": "num:int" }, { "xpath": "number_purchased" }, { "const": "price:float" }, { "xpath": "item_price" } ] }} 

to:

 "total_price": { "custom_func": { "name": "javascript", "args": [ { "const": "var total=0; for (i=0; i<Math.min(num.length,price.length); i++) { total+=num[i]*price[i]; } total; " }, { "const": "num:int:array" }, { "xpath": "number_purchased" }, { "const": "price:float:array" }, { "xpath": "item_price" } ] }} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions