Improved speed of .load
This commit is contained in:
parent
0e7f1bfb69
commit
049b760440
2 changed files with 30 additions and 25 deletions
|
@ -15,6 +15,7 @@ class Locale < ApplicationModel
|
||||||
|
|
||||||
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
|
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
result.data.each {|locale|
|
result.data.each {|locale|
|
||||||
exists = Locale.where(locale: locale['locale']).first
|
exists = Locale.where(locale: locale['locale']).first
|
||||||
if exists
|
if exists
|
||||||
|
@ -23,6 +24,7 @@ class Locale < ApplicationModel
|
||||||
Locale.create(locale.symbolize_keys!)
|
Locale.create(locale.symbolize_keys!)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ load translations from online
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
raise "Can't load translations from #{url}: #{result.error}" if !result.success?
|
raise "Can't load translations from #{url}: #{result.error}" if !result.success?
|
||||||
|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
result.data.each {|translation|
|
result.data.each {|translation|
|
||||||
#puts translation.inspect
|
#puts translation.inspect
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ load translations from online
|
||||||
Translation.create(translation.symbolize_keys!)
|
Translation.create(translation.symbolize_keys!)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue