Class: Hubstats::ReposController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Hubstats::ReposController
- Defined in:
- app/controllers/hubstats/repos_controller.rb
Instance Method Summary collapse
Instance Method Details
#dashboard ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/hubstats/repos_controller.rb', line 39 def dashboard @repos = Hubstats::Repo.with_recent_activity(@timespan).limit(20) @users = Hubstats::User.with_pulls_or_comments(@timespan).only_active.limit(20) @repo_count = Hubstats::Repo.with_recent_activity(@timespan).count(:all) @user_count = Hubstats::User.with_pulls_or_comments(@timespan).only_active.length @stats = { user_count: @user_count, deploy_count: Hubstats::Deploy.count(:all), pull_count: Hubstats::PullRequest.merged_since(@timespan).count(:all), comment_count: Hubstats::Comment.created_since(@timespan).count(:all), avg_additions: Hubstats::PullRequest.merged_since(@timespan).average(:additions).to_i, avg_deletions: Hubstats::PullRequest.merged_since(@timespan).average(:deletions).to_i } end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/hubstats/repos_controller.rb', line 6 def index if params[:query] @repos = Hubstats::Repo.where("name LIKE ?", "%#{params[:query]}%").order("name ASC") elsif params[:id] @repos = Hubstats::Repo.where(id: params[:id].split(",")).order("name ASC") else @repos = Hubstats::Repo.with_recent_activity(@timespan) end respond_to do |format| format.json { render :json => @repos} end end |
#show ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/hubstats/repos_controller.rb', line 20 def show @repo = Hubstats::Repo.where(name: params[:repo]).first @pull_requests = Hubstats::PullRequest.belonging_to_repo(@repo.id).updated_since(@timespan).order("updated_at DESC").limit(20) @users = Hubstats::User.with_pulls_or_comments(@timespan,@repo.id).only_active.limit(20) @pull_count = Hubstats::PullRequest.belonging_to_repo(@repo.id).updated_since(@timespan).count(:all) @deploy_count = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_since(@timespan).count(:all) @user_count = Hubstats::User.with_pulls_or_comments(@timespan,@repo.id).only_active.length @stats = { user_count: @user_count, deploy_count: @deploy_count, pull_count: @pull_count, comment_count: Hubstats::Comment.belonging_to_repo(@repo.id).created_since(@timespan).count(:all), avg_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:additions).to_i, avg_deletions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:deletions).to_i, net_additions: Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:additions).to_i - Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:deletions).to_i } end |