Created
October 9, 2017 13:08
-
-
Save beeflamian/b4b92419ab4de81eaa99dc4ccdd505e7 to your computer and use it in GitHub Desktop.
shuttle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locales = Set.new | |
stat = {} | |
projects = ['Android Register', 'Dashboard (New)', 'iOS Dashboard', 'iOS Register', 'IRF Forms', 'Public Web', 'Regulator Emails', 'solidshop', 'Help Center Articles', 'Payroll', 'Square / Web', 'Macro Texts'] | |
start_t = Time.current.beginning_of_year | |
end_t = start_t.end_of_month | |
while start_t < Time.current do | |
File.open("/app/shuttle/current/translations_stat_#{start_t.month}.csv", 'w') do |f| | |
projects.each do |p| | |
project = Project.find_by_name(p) | |
stat[project.name] = {} | |
name = project.name | |
stat[name]['source'] = 0 | |
keys = Set.new | |
project.translations.where(created_at: start_t..end_t).each do |t| | |
unless keys.include?(t.key.id) | |
stat[name]['source'] += t.words_count | |
keys.add(t.key.id) | |
end | |
unless t.key.is_block_tag | |
locale = t.rfc5646_locale | |
locales.add(locale) | |
stat[name][locale] = 0 unless stat[name][locale] | |
stat[name][locale] += t.words_count if t.translated | |
end | |
end | |
end | |
locales = locales.to_a | |
title = "project source " + locales.join(' ') | |
f.write("#{title}\n") | |
stat.each do |project, data| | |
output = "#{project} #{data['source']}" | |
locales.each do |locale| | |
if data[locale] | |
output += " #{data[locale]}" | |
else | |
output += " 0" | |
end | |
end | |
f.write("#{output}\n") | |
end | |
end | |
start_t = end_t + 1 | |
end_t = start_t.end_of_month | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment