gorules / zen

Open-source Business Rules Engine for your Rust, NodeJS, Python or Go applications.
https://gorules.io
MIT License
835 stars 80 forks source link

Provide count distinct functionality #265

Closed TheCaffinatedDeveloper closed 4 weeks ago

TheCaffinatedDeveloper commented 4 weeks ago

We have been loving the ZEN rules engine and it's ease of use. The javascript function "escape hatch" is quite nice and allows for some extensive capabilities. I will say however, the ability to count distinct elements in an array would be much appreciated.

My recommendations: if the element in the array is a "zen primitive" such as number, date, string etc it should be fairly straightforward (and perhaps that's the first support). If its a context then the user could provide a callback that returns a string of concatenated properties that make this context unique etc.

I know this can be done using javascript functions but it would be nice to be able to do count_distinct([date, date, date]) out of the box to calculate number of distinct dates for example. Or len(distinct([date, date, date]))

ivanmiletic commented 4 weeks ago

Good suggestion, added to backlog