Speedup of syncing translations.

This commit is contained in:
Martin Edenhofer 2015-11-18 08:37:18 +01:00
parent 042365b533
commit 47714f7042

View file

@ -44,16 +44,17 @@ dedicated:
) )
fail "Can't load translations from #{url}: #{result.error}" if !result.success? fail "Can't load translations from #{url}: #{result.error}" if !result.success?
translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
result.data.each {|translation_raw| result.data.each {|translation_raw|
# handle case insensitive sql # handle case insensitive sql
exists = Translation.where(locale: translation_raw['locale'], format: translation_raw['format'], source: translation_raw['source'])
translation = nil translation = nil
exists.each {|item| translations.each {|item|
if item.source == translation_raw['source'] next if item.format != translation_raw['format']
translation = item next if item.source != translation_raw['source']
end translation = item
break
} }
if translation if translation