From 639784ec815dddbcd4ddacd27388c8a17faeecc8 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 2 Aug 2017 15:09:07 +0900 Subject: [PATCH] Fix rubocop offenses. --- plugin.rb | 58 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/plugin.rb b/plugin.rb index 355453d..58d878e 100644 --- a/plugin.rb +++ b/plugin.rb @@ -17,7 +17,7 @@ after_initialize do unless $redis.get('solved_already_upgraded') unless UserAction.where(action_type: UserAction::SOLVED).exists? Rails.logger.info("Upgrading storage for solved") - sql =< 0 and !topic.closed + if (auto_close_hours = SiteSetting.solved_topics_auto_close_hours) > (0) && !topic.closed topic.set_or_create_timer( TopicTimer.types[:close], auto_close_hours, @@ -187,17 +189,17 @@ SQL accepted_solutions = TopicCustomField.where(name: "accepted_answer_post_id") accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id = ?", report.category_id) if report.category_id accepted_solutions.where("topic_custom_fields.created_at >= ?", report.start_date) - .where("topic_custom_fields.created_at <= ?", report.end_date) - .group("DATE(topic_custom_fields.created_at)") - .order("DATE(topic_custom_fields.created_at)") - .count - .each do |date, count| + .where("topic_custom_fields.created_at <= ?", report.end_date) + .group("DATE(topic_custom_fields.created_at)") + .order("DATE(topic_custom_fields.created_at)") + .count + .each do |date, count| report.data << { x: date, y: count } end report.total = accepted_solutions.count report.prev30Days = accepted_solutions.where("topic_custom_fields.created_at >= ?", report.start_date - 30.days) - .where("topic_custom_fields.created_at <= ?", report.start_date) - .count + .where("topic_custom_fields.created_at <= ?", report.start_date) + .count end end @@ -243,9 +245,9 @@ SQL def accepted_answer_post_info # TODO: we may already have it in the stream ... so bypass query here postInfo = Post.where(id: accepted_answer_post_id, topic_id: object.topic.id) - .joins(:user) - .pluck('post_number', 'username', 'cooked') - .first + .joins(:user) + .pluck('post_number', 'username', 'cooked') + .first if postInfo postInfo[2] = PrettyText.excerpt(postInfo[2], SiteSetting.solved_quote_length)