FIX: correctly count assigned topics for user

Previously we were looking at deleted topics
This commit is contained in:
Sam Saffron 2019-05-03 11:24:16 +10:00
parent 8583287faf
commit 6f031f5432
1 changed files with 4 additions and 4 deletions

View File

@ -134,11 +134,11 @@ SQL
return true if @assigned_by.id == user.id
assigned_total = TopicCustomField
.where('name = ? OR name = ?', ASSIGNED_TO_ID, ASSIGNED_BY_ID)
.joins(:topic)
.where(topics: { deleted_at: nil })
.where(name: ASSIGNED_TO_ID)
.where(value: user.id)
.group(:topic_id)
.having('COUNT(*) = 1')
.count.length
.count
assigned_total < SiteSetting.max_assigned_topics
end