martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
405 stars 23 forks source link

Add the ability to compute the average of a given column in query sets #149

Closed treagod closed 7 months ago

treagod commented 7 months ago

This pull request introduces the ability to calculate the average of a column as shown below

# Calculates the average price for all products
Product.average(:price)
# Calculates the average for a subset of products
awesome_products = Product.filter(name__startswith: "Awesome")
awesome_products.average(:price)

Closes #144