Module: Vulgata::AdminHelper

Defined in:
app/helpers/vulgata/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#locale_progress_percentage(locale) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/vulgata/admin_helper.rb', line 3

def locale_progress_percentage locale
  if TranslationState.any?
    approved_for_locale = TranslationState.where(locale: locale).where(status: Vulgata::TranslationState.statuses[:approved]).count.to_f
    sources_of_other_locales = TranslationState.where.not(locale: locale).where(status: Vulgata::TranslationState.statuses[:source]).count.to_f
    return sources_of_other_locales == 0 ? 100 : (approved_for_locale / sources_of_other_locales  * 100).floor
  end
end