15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/i18n/backend/weeler/usage_logger.rb', line 15
def dump_key_usage
already_dumped = i18n_cache.read([:dump_usage_stats, Process.pid]).present?
unless already_dumped
Weeler::Lock.acquire('usage_stats_dump') do
i18n_cache.instance_variable_get(:@data).keys.each do |key|
if key.start_with?('usage_stats')
translation_stat = TranslationStat.find_or_create_by(key: key.gsub('usage_stats/en/', ''))
translation_stat.usage_count += i18n_cache.read(key).to_i
translation_stat.save!
end
end
i18n_cache.write [:dump_usage_stats, Process.pid], Process.pid
end
end
end
|