From 45fd474f495fa4c742093b1e04b8aaaff34f6592 Mon Sep 17 00:00:00 2001 From: shreyas098 Date: Mon, 23 Aug 2021 11:59:53 +0530 Subject: [PATCH] Fix appointment code climate --- app/models/appointment_slot_preset.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/appointment_slot_preset.rb b/app/models/appointment_slot_preset.rb index ddbcabd30..df6721199 100644 --- a/app/models/appointment_slot_preset.rb +++ b/app/models/appointment_slot_preset.rb @@ -12,18 +12,18 @@ class AppointmentSlotPreset < ApplicationRecord after_save :push_changes after_destroy :push_changes - push_targets [ Channel::STOCK_CHANNEL ] + push_targets [Channel::STOCK_CHANNEL] private def no_conflict conflicts = AppointmentSlotPreset - .where({ day: day, hours: hours, minutes: minutes }) - .where.not({ id: self.id }) - .count + .where({ day: day, hours: hours, minutes: minutes }) + .where.not({ id: self.id }) + .count - if conflicts.positive? - errors.add(:base, I18n.t("appointment_slots.already_exists")) - end + return unless conflicts.positive? + + errors.add(:base, I18n.t("appointment_slots.already_exists")) end end