Fix active ordergroup

This commit is contained in:
Patrick Gansterer 2021-03-17 13:12:13 +01:00
parent cdc9e91d26
commit 6d71bd2c2f
2 changed files with 3 additions and 1 deletions

View file

@ -7,7 +7,7 @@ class Foodcoop::OrdergroupsController < ApplicationController
end end
if params[:only_active] # Select only active groups if params[:only_active] # Select only active groups
@ordergroups = @ordergroups.joins(:orders).where("orders.starts >= ?", Time.now.months_ago(3)).uniq @ordergroups = @ordergroups.active
end end
@ordergroups = @ordergroups.page(params[:page]).per(@per_page) @ordergroups = @ordergroups.page(params[:page]).per(@per_page)

View file

@ -20,6 +20,8 @@ class Ordergroup < Group
after_create :update_stats! after_create :update_stats!
scope :active, -> { joins(:orders).where(orders: { starts: (Time.now.months_ago(3)..) }).group(:id) }
def contact def contact
"#{contact_phone} (#{contact_person})" "#{contact_phone} (#{contact_person})"
end end