app/controllers/hubstats/repos_controller.rb in hubstats-0.3.13 vs app/controllers/hubstats/repos_controller.rb in hubstats-0.3.14
- old
+ new
@@ -2,58 +2,58 @@
module Hubstats
class ReposController < ApplicationController
def index
- if params[:query]
+ if params[:query] ## For select 2
@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)
+ @repos = Hubstats::Repo.with_recent_activity(@start_date, @end_date)
end
respond_to do |format|
format.json { render :json => @repos}
end
end
def show
@repo = Hubstats::Repo.where(name: params[:repo]).first
- @pull_requests = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_since(@timespan).order("updated_at DESC").limit(20)
- @pull_count = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_since(@timespan).count(:all)
- @deploys = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_since(@timespan).order("deployed_at DESC").limit(20)
- @deploy_count = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_since(@timespan).count(:all)
- @comment_count = Hubstats::Comment.belonging_to_repo(@repo.id).created_since(@timespan).count(:all)
- @user_count = Hubstats::User.with_pulls_or_comments(@timespan,@repo.id).only_active.length
- @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
- @additions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:additions)
- @deletions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:deletions)
-
+ @pull_requests = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_in_date_range(@start_date, @end_date).order("updated_at DESC").limit(20)
+ @pull_count = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_in_date_range(@start_date, @end_date).count(:all)
+ @deploys = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_in_date_range(@start_date, @end_date).order("deployed_at DESC").limit(20)
+ @deploy_count = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_in_date_range(@start_date, @end_date).count(:all)
+ @comment_count = Hubstats::Comment.belonging_to_repo(@repo.id).created_in_date_range(@start_date, @end_date).count(:all)
+ @user_count = Hubstats::User.with_pulls_or_comments(@start_date, @end_date, @repo.id).only_active.length
+ @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).sum(:additions).to_i -
+ Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).sum(:deletions).to_i
+ @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).average(:additions)
+ @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).average(:deletions)
+
stats
end
def dashboard
- if params[:query] ## For select 2.
+ if params[:query] ## For select 2
@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_all_metrics(@timespan)
+ @repos = Hubstats::Repo.with_all_metrics(@start_date, @end_date)
.with_id(params[:repos])
.custom_order(params[:order])
.paginate(:page => params[:page], :per_page => 15)
end
- @user_count = Hubstats::User.with_pulls_or_comments(@timespan).only_active.length
- @deploy_count = Hubstats::Deploy.deployed_since(@timespan).count(:all)
- @pull_count = Hubstats::PullRequest.merged_since(@timespan).count(:all)
- @comment_count = Hubstats::Comment.created_since(@timespan).count(:all)
- @net_additions = Hubstats::PullRequest.merged_since(@timespan).sum(:additions).to_i -
- Hubstats::PullRequest.merged_since(@timespan).sum(:deletions).to_i
- @additions = Hubstats::PullRequest.merged_since(@timespan).average(:additions)
- @deletions = Hubstats::PullRequest.merged_since(@timespan).average(:deletions)
+ @user_count = Hubstats::User.with_pulls_or_comments(@start_date, @end_date).only_active.length
+ @deploy_count = Hubstats::Deploy.deployed_in_date_range(@start_date, @end_date).count(:all)
+ @pull_count = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).count(:all)
+ @comment_count = Hubstats::Comment.created_in_date_range(@start_date, @end_date).count(:all)
+ @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:additions).to_i -
+ Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:deletions).to_i
+ @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:additions)
+ @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:deletions)
stats
respond_to do |format|
format.html