Reduce SQL queries in the study groups controller

Fixes CODEOCEAN-Y7
This commit is contained in:
Sebastian Serth
2023-09-25 22:15:27 +02:00
parent a9d756171b
commit 684639696d
3 changed files with 8 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class StudyGroup < ApplicationRecord
end
def user_count
study_group_memberships.distinct.count
attributes['user_count'] || study_group_memberships.size
end
def to_s