Permalink
Browse files

New statistics endpoint for integrations

  • Loading branch information...
1 parent b555bf0 commit 997231b9766ea459543ed2932e9172863cdf3516 @fcsonline fcsonline committed Mar 4, 2013
Showing with 24 additions and 1 deletion.
  1. +18 −1 app/controllers/tolk/locales_controller.rb
  2. +4 −0 app/models/tolk/locale.rb
  3. +2 −0 config/routes.rb
@@ -6,7 +6,7 @@ class LocalesController < Tolk::ApplicationController
def index
@locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)
end
-
+
def show
respond_to do |format|
format.html do
@@ -43,6 +43,23 @@ def dump_all
redirect_to request.referrer
end
+ def stats
+ @locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)
+
+ respond_to do |format|
+ format.json do
+ stats = @locales.collect do |locale|
+ [locale.name, {
+ :missing => locale.count_phrases_without_translation,
+ :updated => locale.count_phrases_with_updated_translation,
+ :updated_at => locale.updated_at
+ }]
+ end
+ render :json => Hash[stats]
+ end
+ end
+ end
+
private
def find_locale
@@ -89,6 +89,10 @@ def count_phrases_without_translation
Tolk::Phrase.count - existing_ids.count
end
+ def count_phrases_with_updated_translation(page = nil)
+ find_phrases_with_translations(page, :'tolk_translations.primary_updated' => true).count
+ end
+
def phrases_without_translation(page = nil, options = {})
phrases = Tolk::Phrase.scoped(:order => 'tolk_phrases.key ASC')
View
@@ -2,6 +2,8 @@
root :to => 'locales#index'
post "/dump_all" => "locales#dump_all", :as => :dump_all_locales
+ get "/stats" => "locales#stats"
+
resources :locales do
member do
get :all

0 comments on commit 997231b

Please sign in to comment.