From bc2cc858045126b2dd5642328bbb2dbc495c35ed Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Thu, 25 Feb 2021 15:59:42 +0530 Subject: [PATCH] rename n_value to time_n_value --- .../templates/components/wizard-realtime-validations.hbs | 2 +- .../wizard/components/similar-topics-validator.js.es6 | 2 +- lib/custom_wizard/realtime_validations/similar_topics.rb | 8 ++++---- .../realtime_validations/similar_topics_spec.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs b/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs index d4d068ac..4544f28a 100644 --- a/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs @@ -25,7 +25,7 @@
- {{input type="number" class="time-n-value" value=props.n_value}} + {{input type="number" class="time-n-value" value=props.time_n_value}} {{combo-box value=(readonly props.time_unit) content=timeUnits diff --git a/assets/javascripts/wizard/components/similar-topics-validator.js.es6 b/assets/javascripts/wizard/components/similar-topics-validator.js.es6 index d8bc952d..3b63fafb 100644 --- a/assets/javascripts/wizard/components/similar-topics-validator.js.es6 +++ b/assets/javascripts/wizard/components/similar-topics-validator.js.es6 @@ -125,7 +125,7 @@ export default WizardFieldValidator.extend({ title: this.get("field.value"), categories: this.get("validation.categories"), time_unit: this.get("validation.time_unit"), - n_value: this.get("validation.n_value") + time_n_value: this.get("validation.time_n_value") }).then((result) => { const similarTopics = A( deepMerge(result["topics"], result["similar_topics"]) diff --git a/lib/custom_wizard/realtime_validations/similar_topics.rb b/lib/custom_wizard/realtime_validations/similar_topics.rb index 9ec8f60d..117b2681 100644 --- a/lib/custom_wizard/realtime_validations/similar_topics.rb +++ b/lib/custom_wizard/realtime_validations/similar_topics.rb @@ -21,7 +21,7 @@ class CustomWizard::RealtimeValidation::SimilarTopics title = params[:title] raw = params[:raw] categories = params[:categories] - n_value = params[:n_value] + time_n_value = params[:time_n_value] time_unit = params[:time_unit] result = CustomWizard::RealtimeValidation::Result.new(:similar_topic) @@ -33,9 +33,9 @@ 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 n_value.present? and time_unit.present? - if n_value.to_i > 0 - topics.select! { |t| t.created_at >= n_value.to_i.send(time_unit).ago } + 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 end topics.map! { |t| SimilarTopic.new(t) } diff --git a/spec/components/custom_wizard/realtime_validations/similar_topics_spec.rb b/spec/components/custom_wizard/realtime_validations/similar_topics_spec.rb index 1116f019..94b17b63 100644 --- a/spec/components/custom_wizard/realtime_validations/similar_topics_spec.rb +++ b/spec/components/custom_wizard/realtime_validations/similar_topics_spec.rb @@ -35,7 +35,7 @@ describe ::CustomWizard::RealtimeValidation::SimilarTopics do cat_topic.update!(created_at: 2.days.ago) validation = ::CustomWizard::RealtimeValidation::SimilarTopics.new(user) - result = validation.perform({ title: "matching similar", n_value: 1, time_unit: "days" }) + result = validation.perform({ title: "matching similar", time_n_value: 1, time_unit: "days" }) expect(result.items.length).to eq(1) end end