1
0
Fork 0

rename n_value to time_n_value

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-02-25 15:59:42 +05:30
Ursprung c54273b94a
Commit bc2cc85804
4 geänderte Dateien mit 7 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -25,7 +25,7 @@
<label>{{i18n 'admin.wizard.field.validations.time_after'}}</label> <label>{{i18n 'admin.wizard.field.validations.time_after'}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{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 {{combo-box
value=(readonly props.time_unit) value=(readonly props.time_unit)
content=timeUnits content=timeUnits

Datei anzeigen

@ -125,7 +125,7 @@ export default WizardFieldValidator.extend({
title: this.get("field.value"), title: this.get("field.value"),
categories: this.get("validation.categories"), categories: this.get("validation.categories"),
time_unit: this.get("validation.time_unit"), 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) => { }).then((result) => {
const similarTopics = A( const similarTopics = A(
deepMerge(result["topics"], result["similar_topics"]) deepMerge(result["topics"], result["similar_topics"])

Datei anzeigen

@ -21,7 +21,7 @@ class CustomWizard::RealtimeValidation::SimilarTopics
title = params[:title] title = params[:title]
raw = params[:raw] raw = params[:raw]
categories = params[:categories] categories = params[:categories]
n_value = params[:n_value] time_n_value = params[:time_n_value]
time_unit = params[:time_unit] time_unit = params[:time_unit]
result = CustomWizard::RealtimeValidation::Result.new(:similar_topic) 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 = Topic.similar_to(title, raw, user).to_a
topics.select! { |t| categories.include?(t.category.id.to_s) } if categories.present? topics.select! { |t| categories.include?(t.category.id.to_s) } if categories.present?
if n_value.present? and time_unit.present? if time_n_value.present? and time_unit.present?
if n_value.to_i > 0 if time_n_value.to_i > 0
topics.select! { |t| t.created_at >= n_value.to_i.send(time_unit).ago } topics.select! { |t| t.created_at >= time_n_value.to_i.send(time_unit).ago }
end end
end end
topics.map! { |t| SimilarTopic.new(t) } topics.map! { |t| SimilarTopic.new(t) }

Datei anzeigen

@ -35,7 +35,7 @@ describe ::CustomWizard::RealtimeValidation::SimilarTopics do
cat_topic.update!(created_at: 2.days.ago) cat_topic.update!(created_at: 2.days.ago)
validation = ::CustomWizard::RealtimeValidation::SimilarTopics.new(user) 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) expect(result.items.length).to eq(1)
end end
end end