Snippet tag to aggregate the given value from the list of objects

Description

There is a need to add a snippet tag that aggregates the given value from each object given in the list.

Use-case

Sending a promotional campaign only to customers whose deals exceed the value of USD 100.

To-do

Add a snippet tag called aggregate, with parameters:

  • list of json objects

  • the name of the attribute to be aggregated

  • aggregation method name - sum ("sum" parameter) or average ("avg" parameter)

Example

{% aggregate deal_list function="sum" attribute="value" as values_sum %}

where the deal list "deal_list" can be generated with a snippet of the deal tag, i.e.:

{% deals for_last_days=1 count=5 filter_by='created_at' order_by='created_at' order=1 as deal_list %}

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board

🧩 Feature Request

ETA
Jun 29, 2023
Date

About 3 years ago

Author

Grzegorz Kacperski

Subscribe to request

Get notified by email when there are changes.