FIX: take into account unlisted banners

This commit is contained in:
Régis Hanol
2015-06-22 14:08:30 +02:00
parent 41e427bd2e
commit efb02ae561
2 changed files with 24 additions and 6 deletions

View File

@@ -162,12 +162,12 @@ class TopicsController < ApplicationController
params.require(:category_id)
category_id = params[:category_id].to_i
topics = Topic.listable_topics.visible
visible_topics = Topic.listable_topics.visible
render json: {
pinned_in_category_count: topics.where(category_id: category_id).where(pinned_globally: false).where.not(pinned_at: nil).count,
pinned_globally_count: topics.where(pinned_globally: true).where.not(pinned_at: nil).count,
banner_count: topics.where(archetype: Archetype.banner).count,
pinned_in_category_count: visible_topics.where(category_id: category_id).where(pinned_globally: false).where.not(pinned_at: nil).count,
pinned_globally_count: visible_topics.where(pinned_globally: true).where.not(pinned_at: nil).count,
banner_count: Topic.listable_topics.where(archetype: Archetype.banner).count,
}
end