Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b1b4e26a89
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (31 sloc) 1.216 kb
class StatsController < ApplicationController
before_filter :find_rubygem, :only => :show
before_filter :ensure_hosted, :only => :show
def index
@number_of_gems = Rubygem.total_count
@number_of_users = User.count
@number_of_downloads = Download.count
@most_downloaded = Rubygem.downloaded(10)
end
def show
if params[:version_id]
@subtitle = I18n.t('stats.show.for', :for => params[:version_id])
@version = Version.find_from_slug!(@rubygem.id, params[:version_id])
@versions = [@version]
@downloads_today = Download.today(@version)
@rank = Download.rank(@version)
else
@subtitle = I18n.t('stats.show.overview')
@version = @rubygem.versions.most_recent
@versions = @rubygem.versions.indexed.by_built_at.limit(5)
@downloads_today = Download.today(@rubygem.versions)
@rank = Download.highest_rank(@rubygem.versions)
end
@downloads_total = @version.rubygem.downloads
@cardinality = Download.cardinality
end
private
def ensure_hosted
render :file => 'public/404', :status => :not_found if !@rubygem.hosted?
end
end
Jump to Line
Something went wrong with that request. Please try again.