mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-31 03:52:12 +02:00
Merge pull request #1197 from Retrospring/fix/discover-missing-subscriptions
Fix 500 on Discover
This commit is contained in:
commit
cd49558b81
1 changed files with 3 additions and 0 deletions
|
@ -13,6 +13,9 @@ class DiscoverController < ApplicationController
|
||||||
@popular_questions = Question.where("created_at > ?", Time.now.ago(1.week)).order(:answer_count).reverse_order.limit(top_x).includes(:user)
|
@popular_questions = Question.where("created_at > ?", Time.now.ago(1.week)).order(:answer_count).reverse_order.limit(top_x).includes(:user)
|
||||||
@new_users = User.where("asked_count > 0").order(:id).reverse_order.limit(top_x).includes(:profile)
|
@new_users = User.where("asked_count > 0").order(:id).reverse_order.limit(top_x).includes(:profile)
|
||||||
|
|
||||||
|
answer_ids = @popular_answers.map(&:id) + @most_discussed.map(&:id)
|
||||||
|
@subscribed_answer_ids = Subscription.where(user: current_user, answer_id: answer_ids).pluck(:answer_id)
|
||||||
|
|
||||||
# .user = the user
|
# .user = the user
|
||||||
# .question_count = how many questions did the user ask
|
# .question_count = how many questions did the user ask
|
||||||
@users_with_most_questions = Question.select('user_id, COUNT(*) AS question_count').
|
@users_with_most_questions = Question.select('user_id, COUNT(*) AS question_count').
|
||||||
|
|
Loading…
Reference in a new issue