From 8facb44af7b5c15098efae92f23ac8401475b974 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Mon, 27 Nov 2023 22:13:56 +0100 Subject: [PATCH] Fix lint errors --- app/controllers/discover_controller.rb | 6 +++--- app/models/answer.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/discover_controller.rb b/app/controllers/discover_controller.rb index 2af00fc1..05779d99 100644 --- a/app/controllers/discover_controller.rb +++ b/app/controllers/discover_controller.rb @@ -8,8 +8,8 @@ class DiscoverController < ApplicationController top_x = 10 # only display the top X items - @popular_answers = Answer.for_user(current_user).where("created_at > ?", Time.now.ago(1.week)).order(:smile_count).reverse_order.limit(top_x).includes(:question, :user, :comments) - @most_discussed = Answer.for_user(current_user).where("created_at > ?", Time.now.ago(1.week)).order(:comment_count).reverse_order.limit(top_x).includes(:question, :user, :comments) + @popular_answers = Answer.for_user(current_user).where("created_at > ?", Time.now.utc.ago(1.week)).order(:smile_count).reverse_order.limit(top_x).includes(:question, :user, :comments) + @most_discussed = Answer.for_user(current_user).where("created_at > ?", Time.now.utc.ago(1.week)).order(:comment_count).reverse_order.limit(top_x).includes(:question, :user, :comments) @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) @@ -25,7 +25,7 @@ class DiscoverController < ApplicationController # .user = the user # .answer_count = how many questions did the user answer @users_with_most_answers = Answer.select('user_id, COUNT(*) AS answer_count'). - where("created_at > ?", Time.now.ago(1.week)). + where("created_at > ?", week_ago). group(:user_id). order('answer_count'). reverse_order.limit(top_x) diff --git a/app/models/answer.rb b/app/models/answer.rb index 702b7702..e115e9a1 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -27,7 +27,8 @@ class Answer < ApplicationRecord FROM reactions WHERE parent_id = answers.id AND parent_type = 'Answer' - AND user_id = #{current_user.id}) as has_reacted") + AND user_id = #{current_user.id}) as has_reacted", + ) } SHORT_ANSWER_MAX_LENGTH = 640