add groupby to models; add its tests