app/models/lit/source.rb in lit-0.2.3 vs app/models/lit/source.rb in lit-0.2.4

- old
+ new

@@ -34,33 +34,36 @@ result = get_from_remote(LOCALIZATIONS_PATH, {:after=>after}) unless result.nil? if result.is_a?(Array) result.each do |r| il = IncommingLocalization.new - if ::Rails::VERSION::MAJOR<4 + if ::Rails::VERSION::MAJOR < 4 il = IncommingLocalization.where(:incomming_id=>r["id"]).first_or_initialize else il = IncommingLocalization.find_or_initialize_by(:incomming_id=>r["id"]) end il.source = self il.locale_str = r["locale_str"] il.locale = Locale.where(:locale=>il.locale_str).first il.localization_key_str = r["localization_key_str"] il.localization_key = LocalizationKey.where(:localization_key=>il.localization_key_str).first - il.save! - IncommingLocalization.where(:id=>il.id).update_all ['translated_value=?', r["value"]] + unless il.is_duplicate?(r['value']) + il.save! + IncommingLocalization.where(:id=>il.id). + update_all ['translated_value=?', r["value"]] + end end - lc = get_last_change - lc = DateTime.parse(lc) unless lc.nil? - touch_last_updated_at(lc) - self.save + last_change = get_last_change + last_change = DateTime.parse(last_change) unless last_change.nil? + touch_last_updated_at(last_change) + save end end end def touch_last_updated_at! touch_last_updated_at - self.save + save end private def touch_last_updated_at(time=nil) self.last_updated_at = time || Time.now