From 33e457a5c9e6ee3153a3ea69bf2fd2f4b84861a5 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Fri, 26 Feb 2021 09:46:23 +0530 Subject: [PATCH] simplified the conditional --- lib/custom_wizard/realtime_validations/similar_topics.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/custom_wizard/realtime_validations/similar_topics.rb b/lib/custom_wizard/realtime_validations/similar_topics.rb index 117b2681..189054cc 100644 --- a/lib/custom_wizard/realtime_validations/similar_topics.rb +++ b/lib/custom_wizard/realtime_validations/similar_topics.rb @@ -33,10 +33,8 @@ class CustomWizard::RealtimeValidation::SimilarTopics topics = Topic.similar_to(title, raw, user).to_a topics.select! { |t| categories.include?(t.category.id.to_s) } if categories.present? - if time_n_value.present? and time_unit.present? - if time_n_value.to_i > 0 - topics.select! { |t| t.created_at >= time_n_value.to_i.send(time_unit).ago } - end + if time_n_value.to_i > 0 && time_unit.present? + topics.select! { |t| t.created_at >= time_n_value.to_i.send(time_unit).ago } end topics.map! { |t| SimilarTopic.new(t) }