hubstats 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDAxN2M4MjI1MTU0NjMyNGIxZjJmZDUxZTExNTY0ZmRjMDU3ZmJkYw==
4
+ MTU5NGI4YWFlZjBjMTUzOTEwMjk3NDExMDU4OTk2MjM3OTQ4NmYzMQ==
5
5
  data.tar.gz: !binary |-
6
- NTVhOWIzOTcyYzgzYzA4YzU4ZDY2OGRhZTE4NzBjNTJiZGVmMjRjOQ==
6
+ NTFmYjkwNjdmMmU5MDUwYjA3MmI1ZDA4OTNkMTJjZTgyNGEyMGMzOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmZjMTQ3MmQ5OGJmMzc1OGRiMDNjYTg1YTdlZGMyODFmNzI5ODU3Y2YyMzA3
10
- MmY4YzNiNGMzMDcyNGQ3MGNiNGQ0ZTg1NGFmNTVhZmRhMjY3NGM0ODBjMWIz
11
- OWE1MWI4MTQ3Y2ZhOGVhMmQ5NzkyZGFhOTUwMWZiYWQwOGE0YzQ=
9
+ MjIxMjNmMmJlNmRhNGZkZWZjZDc5MDI4ZjlkZTMwMmU5MzllYjE3YmZjNGM1
10
+ MWZhMDBjN2U1NWE5MDk0OGZhOTk1NDJmZGY3OTA5ZDQ1MDEyNzQwMTM5YWFi
11
+ OWIyMDQzNGIwNGExZDJjZmZhNmQxNjA2NDY5MDY3NzI3ZWVhOWU=
12
12
  data.tar.gz: !binary |-
13
- YmMyOThlM2M5NTg1YTA1MjJkODczNmQ5MWZkMjM0MDcxNzY1ODRlYTlmZDA0
14
- OTYxMDNlYjJiMTQzNjUwODQ1NWU4Nzg5MjcwOWIyMzdiNzIwNDhhMjcwM2E0
15
- OTdlNTY5OTY4NTQ5ZDhmZTIzYzQzNmVmZTNlYzBjOGIzZjM0Nzk=
13
+ NWEzNGI2NWRlNThlMzBkMGNjM2M5MTYwMWNjMTMxMGQwYmI0MWY3ZjZiMGM0
14
+ ZjQwOTY4YmFkMDJmZTZhMzg1ZjFlMTM3NWNhOWQyZDBiZjI4NjcxN2NkYmY5
15
+ ODZhYTQzZTViNjMxMTlhZDExYWJjYWQ3MTVmMTBiODUyYTQ1NjU=
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ #### v0.3.14
2
+ * Replacing timespan with a start date and an end date
3
+
4
+ > Emma Sax: Andy Fleener: https://github.com/sportngin/hubstats/pull/65
5
+
1
6
  #### v0.3.13
2
7
  * Adding the nagivation bar highlights
3
8
 
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
  # jquery-rails is used by the dummy application
9
9
  gem "jquery-rails"
10
10
  gem "mysql2"
11
+ gem "bootstrap-datepicker-rails"
11
12
  # Declare any dependencies that are still in development here instead of in
12
13
  # your gemspec. These might include edge Rails or gems from your path or
13
14
  # Git. Remember to move these dependencies to your gemspec before releasing
@@ -14,21 +14,20 @@
14
14
  //= require jquery_ujs
15
15
  //= require select2
16
16
  //= require hubstats/bootstrap
17
+ //= require bootstrap-datepicker
17
18
  //= require_tree .
18
19
 
19
-
20
20
  $(document).ready( function() {
21
- setTimespan()
21
+ setDateRange()
22
22
  });
23
23
 
24
- function setTimespan() {
24
+ function setDateRange() {
25
25
  var index = readCookie("hubstats_index") || 2;
26
26
  var timer = document.getElementById("time-select");
27
27
 
28
28
  timer.selectedIndex = index;
29
29
 
30
30
  timer.onchange = function() {
31
-
32
31
  createCookie("hubstats_index",this.selectedIndex,1);
33
32
  window.location.reload();
34
33
  };
@@ -12,10 +12,10 @@
12
12
  *= require hubstats/bootstrap
13
13
  *= require select2
14
14
  *= require select2-bootstrap
15
+ *= require bootstrap-datepicker
15
16
  *= require_tree .
16
17
  */
17
18
 
18
-
19
19
  .numeric, .title {
20
20
  text-align: center;
21
21
  }
@@ -6,7 +6,8 @@ module Hubstats
6
6
  private
7
7
  def set_time
8
8
  cookies[:hubstats_index] ||= 2
9
- @timespan = TIMESPAN_ARRAY[cookies[:hubstats_index].to_i][:date].ago.to_date
9
+ @start_date = DATE_RANGE_ARRAY[cookies[:hubstats_index].to_i][:date].ago.to_date
10
+ @end_date = Date.today
10
11
  end
11
12
  end
12
13
  end
@@ -8,7 +8,7 @@ module Hubstats
8
8
  @deploys = Hubstats::Deploy.includes(:repo, :pull_requests, :user)
9
9
  .belonging_to_users(params[:users]).belonging_to_repos(params[:repos])
10
10
  .group_by(params[:group])
11
- .order_with_timespan(@timespan, params[:order])
11
+ .order_with_date_range(@start_date, @end_date, params[:order])
12
12
  .paginate(:page => params[:page], :per_page => 15)
13
13
 
14
14
  grouping(params[:group], @deploys)
@@ -6,13 +6,13 @@ module Hubstats
6
6
  def index
7
7
  URI.decode(params[:label]) if params[:label]
8
8
 
9
- pull_requests = PullRequest.all_filtered(params, @timespan)
9
+ pull_requests = PullRequest.all_filtered(params, @start_date, @end_date)
10
10
  @labels = Hubstats::Label.count_by_pull_requests(pull_requests).order("pull_request_count DESC")
11
11
 
12
12
  @pull_requests = Hubstats::PullRequest.includes(:user, :repo)
13
13
  .belonging_to_users(params[:users]).belonging_to_repos(params[:repos])
14
14
  .group_by(params[:group]).with_label(params[:label])
15
- .state_based_order(@timespan,params[:state],params[:order])
15
+ .state_based_order(@start_date, @end_date, params[:state], params[:order])
16
16
  .paginate(:page => params[:page], :per_page => 15)
17
17
 
18
18
  grouping(params[:group], @pull_requests)
@@ -21,9 +21,10 @@ module Hubstats
21
21
  def show
22
22
  @repo = Hubstats::Repo.where(name: params[:repo]).first
23
23
  @pull_request = Hubstats::PullRequest.belonging_to_repo(@repo.id).where(id: params[:id]).first
24
- @comments = Hubstats::Comment.belonging_to_pull_request(params[:id]).created_since(@timespan).limit(20)
25
- comment_count = Hubstats::Comment.belonging_to_pull_request(params[:id]).created_since(@timespan).count(:all)
24
+ @comments = Hubstats::Comment.belonging_to_pull_request(params[:id]).created_in_date_range(@start_date, @end_date).limit(20)
25
+ comment_count = Hubstats::Comment.belonging_to_pull_request(params[:id]).created_in_date_range(@start_date, @end_date).count(:all)
26
26
  @deploys = Hubstats::Deploy.where(id: @pull_request.deploy_id).order("deployed_at DESC")
27
+
27
28
  @stats_basics = {
28
29
  comment_count: comment_count,
29
30
  net_additions: @pull_request.additions.to_i - @pull_request.deletions.to_i,
@@ -4,12 +4,12 @@ module Hubstats
4
4
  class ReposController < ApplicationController
5
5
 
6
6
  def index
7
- if params[:query]
7
+ if params[:query] ## For select 2
8
8
  @repos = Hubstats::Repo.where("name LIKE ?", "%#{params[:query]}%").order("name ASC")
9
9
  elsif params[:id]
10
10
  @repos = Hubstats::Repo.where(id: params[:id].split(",")).order("name ASC")
11
11
  else
12
- @repos = Hubstats::Repo.with_recent_activity(@timespan)
12
+ @repos = Hubstats::Repo.with_recent_activity(@start_date, @end_date)
13
13
  end
14
14
 
15
15
  respond_to do |format|
@@ -19,40 +19,40 @@ module Hubstats
19
19
 
20
20
  def show
21
21
  @repo = Hubstats::Repo.where(name: params[:repo]).first
22
- @pull_requests = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_since(@timespan).order("updated_at DESC").limit(20)
23
- @pull_count = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_since(@timespan).count(:all)
24
- @deploys = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_since(@timespan).order("deployed_at DESC").limit(20)
25
- @deploy_count = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_since(@timespan).count(:all)
26
- @comment_count = Hubstats::Comment.belonging_to_repo(@repo.id).created_since(@timespan).count(:all)
27
- @user_count = Hubstats::User.with_pulls_or_comments(@timespan,@repo.id).only_active.length
28
- @net_additions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:additions).to_i -
29
- Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).sum(:deletions).to_i
30
- @additions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:additions)
31
- @deletions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_repo(@repo.id).average(:deletions)
32
-
22
+ @pull_requests = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_in_date_range(@start_date, @end_date).order("updated_at DESC").limit(20)
23
+ @pull_count = Hubstats::PullRequest.belonging_to_repo(@repo.id).merged_in_date_range(@start_date, @end_date).count(:all)
24
+ @deploys = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_in_date_range(@start_date, @end_date).order("deployed_at DESC").limit(20)
25
+ @deploy_count = Hubstats::Deploy.belonging_to_repo(@repo.id).deployed_in_date_range(@start_date, @end_date).count(:all)
26
+ @comment_count = Hubstats::Comment.belonging_to_repo(@repo.id).created_in_date_range(@start_date, @end_date).count(:all)
27
+ @user_count = Hubstats::User.with_pulls_or_comments(@start_date, @end_date, @repo.id).only_active.length
28
+ @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).sum(:additions).to_i -
29
+ Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).sum(:deletions).to_i
30
+ @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).average(:additions)
31
+ @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_repo(@repo.id).average(:deletions)
32
+
33
33
  stats
34
34
  end
35
35
 
36
36
  def dashboard
37
- if params[:query] ## For select 2.
37
+ if params[:query] ## For select 2
38
38
  @repos = Hubstats::Repo.where("name LIKE ?", "%#{params[:query]}%").order("name ASC")
39
39
  elsif params[:id]
40
40
  @repos = Hubstats::Repo.where(id: params[:id].split(",")).order("name ASC")
41
41
  else
42
- @repos = Hubstats::Repo.with_all_metrics(@timespan)
42
+ @repos = Hubstats::Repo.with_all_metrics(@start_date, @end_date)
43
43
  .with_id(params[:repos])
44
44
  .custom_order(params[:order])
45
45
  .paginate(:page => params[:page], :per_page => 15)
46
46
  end
47
47
 
48
- @user_count = Hubstats::User.with_pulls_or_comments(@timespan).only_active.length
49
- @deploy_count = Hubstats::Deploy.deployed_since(@timespan).count(:all)
50
- @pull_count = Hubstats::PullRequest.merged_since(@timespan).count(:all)
51
- @comment_count = Hubstats::Comment.created_since(@timespan).count(:all)
52
- @net_additions = Hubstats::PullRequest.merged_since(@timespan).sum(:additions).to_i -
53
- Hubstats::PullRequest.merged_since(@timespan).sum(:deletions).to_i
54
- @additions = Hubstats::PullRequest.merged_since(@timespan).average(:additions)
55
- @deletions = Hubstats::PullRequest.merged_since(@timespan).average(:deletions)
48
+ @user_count = Hubstats::User.with_pulls_or_comments(@start_date, @end_date).only_active.length
49
+ @deploy_count = Hubstats::Deploy.deployed_in_date_range(@start_date, @end_date).count(:all)
50
+ @pull_count = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).count(:all)
51
+ @comment_count = Hubstats::Comment.created_in_date_range(@start_date, @end_date).count(:all)
52
+ @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:additions).to_i -
53
+ Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).sum(:deletions).to_i
54
+ @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:additions)
55
+ @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).average(:deletions)
56
56
 
57
57
  stats
58
58
 
@@ -9,7 +9,7 @@ module Hubstats
9
9
  elsif params[:id]
10
10
  @users = Hubstats::User.where(id: params[:id].split(",")).order("login ASC")
11
11
  else
12
- @users = Hubstats::User.only_active.with_all_metrics(@timespan)
12
+ @users = Hubstats::User.only_active.with_all_metrics(@start_date, @end_date)
13
13
  .with_id(params[:users])
14
14
  .custom_order(params[:order])
15
15
  .paginate(:page => params[:page], :per_page => 15)
@@ -23,15 +23,15 @@ module Hubstats
23
23
 
24
24
  def show
25
25
  @user = Hubstats::User.where(login: params[:id]).first
26
- @pull_requests = Hubstats::PullRequest.belonging_to_user(@user.id).merged_since(@timespan).order("updated_at DESC").limit(20)
27
- @pull_count = Hubstats::PullRequest.belonging_to_user(@user.id).merged_since(@timespan).count(:all)
28
- @deploys = Hubstats::Deploy.belonging_to_user(@user.id).deployed_since(@timespan).order("deployed_at DESC").limit(20)
29
- @deploy_count = Hubstats::Deploy.belonging_to_user(@user.id).deployed_since(@timespan).count(:all)
30
- @comment_count = Hubstats::Comment.belonging_to_user(@user.id).created_since(@timespan).count(:all)
31
- @net_additions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).sum(:additions).to_i -
32
- Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).sum(:deletions).to_i
33
- @additions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).average(:additions)
34
- @deletions = Hubstats::PullRequest.merged_since(@timespan).belonging_to_user(@user.id).average(:deletions)
26
+ @pull_requests = Hubstats::PullRequest.belonging_to_user(@user.id).merged_in_date_range(@start_date, @end_date).order("updated_at DESC").limit(20)
27
+ @pull_count = Hubstats::PullRequest.belonging_to_user(@user.id).merged_in_date_range(@start_date, @end_date).count(:all)
28
+ @deploys = Hubstats::Deploy.belonging_to_user(@user.id).deployed_in_date_range(@start_date, @end_date).order("deployed_at DESC").limit(20)
29
+ @deploy_count = Hubstats::Deploy.belonging_to_user(@user.id).deployed_in_date_range(@start_date, @end_date).count(:all)
30
+ @comment_count = Hubstats::Comment.belonging_to_user(@user.id).created_in_date_range(@start_date, @end_date).count(:all)
31
+ @net_additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_user(@user.id).sum(:additions).to_i -
32
+ Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_user(@user.id).sum(:deletions).to_i
33
+ @additions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_user(@user.id).average(:additions)
34
+ @deletions = Hubstats::PullRequest.merged_in_date_range(@start_date, @end_date).belonging_to_user(@user.id).average(:deletions)
35
35
 
36
36
  stats
37
37
  end
@@ -8,7 +8,7 @@ module Hubstats
8
8
  .group("hubstats_comments.user_id")
9
9
  }
10
10
 
11
- scope :created_since, lambda {|time| where("created_at > ?", time) }
11
+ scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_comments.created_at BETWEEN ? AND ?", start_date, end_date)}
12
12
  scope :belonging_to_pull_request, lambda {|pull_request_id| where(pull_request_id: pull_request_id)}
13
13
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
14
14
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
@@ -8,13 +8,12 @@ module Hubstats
8
8
  self.deployed_at = Time.now.getutc if deployed_at.nil?
9
9
  end
10
10
 
11
- scope :deployed_since, lambda {|time| where("hubstats_deploys.deployed_at > ?", time)}
11
+ scope :deployed_in_date_range, lambda {|start_date, end_date| where("hubstats_deploys.deployed_at BETWEEN ? AND ?", start_date, end_date)}
12
12
  scope :group, lambda {|group| group_by(:repo_id) if group }
13
13
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
14
14
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
15
15
  scope :belonging_to_repos, lambda {|repo_id| where(repo_id: repo_id.split(',')) if repo_id}
16
16
  scope :belonging_to_users, lambda {|user_id| where(user_id: user_id.split(',')) if user_id}
17
- scope :order_with_timespan
18
17
  scope :with_repo_name, select('DISTINCT hubstats_repos.name as repo_name, hubstats_deploys.*').joins("LEFT JOIN hubstats_repos ON hubstats_repos.id = hubstats_deploys.repo_id")
19
18
  scope :with_user_name, select('DISTINCT hubstats_users.login as user_name, hubstats_deploys.*').joins("LEFT JOIN hubstats_users ON hubstats_users.id = hubstats_deploys.user_id")
20
19
 
@@ -24,10 +23,10 @@ module Hubstats
24
23
  belongs_to :repo
25
24
  has_many :pull_requests
26
25
 
27
- # Order the data in a given timespan in a given order
28
- def self.order_with_timespan(timespan, order)
26
+ # Order the data in a given date range in a given order
27
+ def self.order_with_date_range(start_date, end_date, order)
29
28
  order = ["ASC", "DESC"].detect{|order_type| order_type.to_s == order.to_s.upcase } || "DESC"
30
- deployed_since(timespan).order("hubstats_deploys.deployed_at #{order}")
29
+ deployed_in_date_range(start_date, end_date).order("hubstats_deploys.deployed_at #{order}")
31
30
  end
32
31
 
33
32
  # Sorts based on whether data is being grouped by user or repo
@@ -10,7 +10,7 @@ module Hubstats
10
10
  .order("pull_request_count DESC")
11
11
  end
12
12
 
13
- scope :with_ids, lambda { |pull_ids| (where("hubstats_labels_pull_requests.pull_request_id" => pull_ids)) }
13
+ scope :with_ids, lambda {|pull_ids| (where("hubstats_labels_pull_requests.pull_request_id" => pull_ids))}
14
14
 
15
15
  scope :with_state, lambda {|state| (where(state: state) unless state == 'all') if state}
16
16
 
@@ -1,9 +1,9 @@
1
1
  module Hubstats
2
2
  class PullRequest < ActiveRecord::Base
3
- scope :closed_since, lambda {|time| where("hubstats_pull_requests.closed_at > ?", time) }
4
- scope :updated_since, lambda {|time| where("hubstats_pull_requests.updated_at > ?", time) }
5
- scope :opened_since, lambda {|time| where("hubstats_pull_requests.created_at > ?", time) }
6
- scope :merged_since, lambda {|time| where("hubstats_pull_requests.merged").where("hubstats_pull_requests.merged_at > ?", time) }
3
+ scope :closed_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.closed_at BETWEEN ? AND ?", start_date, end_date)}
4
+ scope :updated_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.updated_at BETWEEN ? AND ?", start_date, end_date)}
5
+ scope :created_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.created_at BETWEEN ? AND ?", start_date, end_date)}
6
+ scope :merged_in_date_range, lambda {|start_date, end_date| where("hubstats_pull_requests.merged").where("hubstats_pull_requests.merged_at BETWEEN ? AND ?", start_date, end_date)}
7
7
  scope :belonging_to_repo, lambda {|repo_id| where(repo_id: repo_id)}
8
8
  scope :belonging_to_user, lambda {|user_id| where(user_id: user_id)}
9
9
  scope :belonging_to_deploy, lambda {|deploy_id| where(deploy_id: deploy_id)}
@@ -11,12 +11,12 @@ module Hubstats
11
11
  scope :belonging_to_users, lambda {|user_id| where(user_id: user_id.split(',')) if user_id}
12
12
  scope :group, lambda {|group| group_by(:repo_id) if group }
13
13
  scope :with_state, lambda {|state| (where(state: state) unless state == 'all') if state}
14
- scope :with_label, lambda { |label_name| ({ :joins => :labels, :conditions => {:hubstats_labels => {name: label_name.split(',')} } }) if label_name }
14
+ scope :with_label, lambda {|label_name| joins(:labels).where(hubstats_labels: {name: label_name.split(',')}) if label_name}
15
15
  scope :distinct, select("DISTINCT hubstats_pull_requests.*")
16
16
  scope :with_repo_name, select('DISTINCT hubstats_repos.name as repo_name, hubstats_pull_requests.*').joins("LEFT JOIN hubstats_repos ON hubstats_repos.id = hubstats_pull_requests.repo_id")
17
17
  scope :with_user_name, select('DISTINCT hubstats_users.login as user_name, hubstats_pull_requests.*').joins("LEFT JOIN hubstats_users ON hubstats_users.id = hubstats_pull_requests.user_id")
18
18
 
19
- attr_accessible :id, :url, :html_url, :diff_url, :patch_url, :issue_url, :commits_url,
19
+ attr_accessible :id, :url, :html_url, :diff_url, :patch_url, :issue_url, :commits_url,
20
20
  :review_comments_url, :review_comment_url, :comments_url, :statuses_url, :number,
21
21
  :state, :title, :body, :created_at, :updated_at, :closed_at, :merged_at,
22
22
  :merge_commit_sha, :merged, :mergeable, :comments, :commits, :additions,
@@ -56,26 +56,26 @@ module Hubstats
56
56
  end
57
57
 
58
58
  def add_labels(labels)
59
- labels.map!{ |label| Hubstats::Label.first_or_create(label) }
59
+ labels.map!{|label| Hubstats::Label.first_or_create(label) }
60
60
  self.labels = labels
61
61
  end
62
62
 
63
- def self.all_filtered(params, timespan)
64
- filter_based_on_timespan(timespan, params[:state])
63
+ def self.all_filtered(params, start_date, end_date)
64
+ filter_based_on_date_range(start_date, end_date, params[:state])
65
65
  .belonging_to_users(params[:users])
66
66
  .belonging_to_repos(params[:repos])
67
67
  end
68
68
 
69
- def self.filter_based_on_timespan(timespan, state)
70
- with_state(state).updated_since(timespan)
69
+ def self.filter_based_on_date_range(start_date, end_date, state)
70
+ with_state(state).updated_in_date_range(start_date, end_date)
71
71
  end
72
72
 
73
- def self.state_based_order(timespan,state,order)
73
+ def self.state_based_order(start_date, end_date, state, order)
74
74
  order = ["ASC","DESC"].detect{|order_type| order_type.to_s == order.to_s.upcase } || "DESC"
75
75
  if state == "closed"
76
- with_state(state).updated_since(timespan).order("hubstats_pull_requests.closed_at #{order}")
76
+ with_state(state).updated_in_date_range(start_date, end_date).order("hubstats_pull_requests.closed_at #{order}")
77
77
  else #state == "open"
78
- with_state(state).updated_since(timespan).order("hubstats_pull_requests.created_at #{order}")
78
+ with_state(state).updated_in_date_range(start_date, end_date).order("hubstats_pull_requests.created_at #{order}")
79
79
  end
80
80
  end
81
81
 
@@ -1,32 +1,32 @@
1
1
  module Hubstats
2
2
  class Repo < ActiveRecord::Base
3
3
 
4
- scope :with_recent_activity, lambda {|time| where("updated_at > ?", time).order("updated_at DESC")}
5
- scope :with_id, lambda {|user_id| where(id: user_id.split(',')) if user_id}
4
+ scope :with_recent_activity, lambda {|start_date, end_date| where("hubstats_repos.updated_at BETWEEN ? AND ?", start_date, end_date).order("updated_at DESC")}
5
+ scope :with_id, lambda {|repo_id| where(id: repo_id.split(',')) if repo_id}
6
6
 
7
- scope :deploys_or_comments_count, lambda {|time, data, began_time, name|
7
+ scope :deploys_count, lambda {|start_date, end_date|
8
8
  select("hubstats_repos.id as repo_id")
9
- .select("IFNULL(COUNT(DISTINCT #{data}.id),0) AS #{name}_count")
10
- .joins("LEFT JOIN #{data} ON #{data}.repo_id = hubstats_repos.id AND #{data}.#{began_time} > '#{time}'")
9
+ .select("IFNULL(COUNT(DISTINCT hubstats_deploys.id),0) AS deploy_count")
10
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_deploys ON hubstats_deploys.repo_id = hubstats_repos.id AND (hubstats_deploys.deployed_at BETWEEN ? AND ?)", start_date, end_date]))
11
11
  .group("hubstats_repos.id")
12
12
  }
13
13
 
14
- scope :deploys_count, lambda {|time|
15
- deploys_or_comments_count(time, "hubstats_deploys", "deployed_at", "deploy")
16
- }
17
-
18
- scope :comments_count, lambda {|time|
19
- deploys_or_comments_count(time, "hubstats_comments", "created_at", "comment")
14
+ scope :comments_count, lambda {|start_date, end_date|
15
+ select("hubstats_repos.id as repo_id")
16
+ .select("IFNULL(COUNT(DISTINCT hubstats_comments.id),0) AS comment_count")
17
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_comments ON hubstats_comments.repo_id = hubstats_repos.id AND (hubstats_comments.created_at BETWEEN ? AND ?)", start_date, end_date]))
18
+ .group("hubstats_repos.id")
20
19
  }
21
20
 
22
- scope :pull_requests_count, lambda {|time|
21
+ scope :pull_requests_count, lambda {|start_date, end_date|
23
22
  select("hubstats_repos.id as repo_id")
24
23
  .select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
25
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND hubstats_pull_requests.merged_at > '#{time}' AND hubstats_pull_requests.merged = '1'")
24
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.repo_id = hubstats_repos.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?)", start_date, end_date]))
25
+ .where("hubstats_pull_requests.merged = '1'")
26
26
  .group("hubstats_repos.id")
27
27
  }
28
28
 
29
- scope :averages, lambda { |time|
29
+ scope :averages, lambda {|start_date, end_date|
30
30
  select("hubstats_repos.id as repo_id")
31
31
  .select("ROUND(IFNULL(AVG(hubstats_pull_requests.additions),0)) AS average_additions")
32
32
  .select("ROUND(IFNULL(AVG(hubstats_pull_requests.deletions),0)) AS average_deletions")
@@ -34,12 +34,12 @@ module Hubstats
34
34
  .group("hubstats_repos.id")
35
35
  }
36
36
 
37
- scope :with_all_metrics, lambda { |time|
37
+ scope :with_all_metrics, lambda {|start_date, end_date|
38
38
  select("hubstats_repos.*, deploy_count, pull_request_count, comment_count, average_additions, average_deletions")
39
- .joins("LEFT JOIN (#{averages(time).to_sql}) AS averages ON averages.repo_id = hubstats_repos.id")
40
- .joins("LEFT JOIN (#{pull_requests_count(time).to_sql}) AS pull_requests ON pull_requests.repo_id = hubstats_repos.id")
41
- .joins("LEFT JOIN (#{comments_count(time).to_sql}) AS comments ON comments.repo_id = hubstats_repos.id")
42
- .joins("LEFT JOIN (#{deploys_count(time).to_sql}) AS deploys ON deploys.repo_id = hubstats_repos.id")
39
+ .joins("LEFT JOIN (#{averages(start_date, end_date).to_sql}) AS averages ON averages.repo_id = hubstats_repos.id")
40
+ .joins("LEFT JOIN (#{pull_requests_count(start_date, end_date).to_sql}) AS pull_requests ON pull_requests.repo_id = hubstats_repos.id")
41
+ .joins("LEFT JOIN (#{comments_count(start_date, end_date).to_sql}) AS comments ON comments.repo_id = hubstats_repos.id")
42
+ .joins("LEFT JOIN (#{deploys_count(start_date, end_date).to_sql}) AS deploys ON deploys.repo_id = hubstats_repos.id")
43
43
  .group("hubstats_repos.id")
44
44
  }
45
45
 
@@ -53,6 +53,7 @@ module Hubstats
53
53
 
54
54
  has_many :pull_requests
55
55
  has_many :deploys
56
+ has_many :comments
56
57
  belongs_to :owner, :class_name => "User", :foreign_key => "id"
57
58
 
58
59
  def self.create_or_update(github_repo)
@@ -3,78 +3,81 @@ module Hubstats
3
3
 
4
4
  scope :with_id, lambda {|user_id| where(id: user_id.split(',')) if user_id}
5
5
 
6
- scope :deploys_or_comments_count, lambda {|time, data, began_time, name|
6
+ scope :deploys_count, lambda {|start_date, end_date|
7
7
  select("hubstats_users.id as user_id")
8
- .select("IFNULL(COUNT(DISTINCT #{data}.id),0) AS #{name}_count")
9
- .joins("LEFT JOIN #{data} ON #{data}.user_id = hubstats_users.id AND #{data}.#{began_time} > '#{time}'")
8
+ .select("IFNULL(COUNT(DISTINCT hubstats_deploys.id),0) AS deploy_count")
9
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_deploys ON hubstats_deploys.user_id = hubstats_users.id AND (hubstats_deploys.deployed_at BETWEEN ? AND ?)", start_date, end_date]))
10
10
  .group("hubstats_users.id")
11
11
  }
12
12
 
13
- scope :deploys_count, lambda {|time|
14
- deploys_or_comments_count(time, "hubstats_deploys", "deployed_at", "deploy")
15
- }
16
-
17
- scope :comments_count, lambda {|time|
18
- deploys_or_comments_count(time, "hubstats_comments", "created_at", "comment")
13
+ scope :comments_count, lambda {|start_date, end_date|
14
+ select("hubstats_users.id as user_id")
15
+ .select("IFNULL(COUNT(DISTINCT hubstats_comments.id),0) AS comment_count")
16
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND (hubstats_comments.created_at BETWEEN ? AND ?)", start_date, end_date]))
17
+ .group("hubstats_users.id")
19
18
  }
20
19
 
21
- scope :pull_requests_count, lambda {|time|
20
+ scope :pull_requests_count, lambda {|start_date, end_date|
22
21
  select("hubstats_users.id as user_id")
23
22
  .select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
24
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.merged_at > '#{time}' AND hubstats_pull_requests.merged = '1'")
23
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.merged_at BETWEEN ? AND ?)", start_date, end_date]))
24
+ .where("hubstats_pull_requests.merged = '1'")
25
25
  .group("hubstats_users.id")
26
26
  }
27
27
 
28
- scope :pull_requests_count_by_repo, lambda {|time,repo_id|
28
+ scope :pull_requests_count_by_repo, lambda {|start_date, end_date, repo_id|
29
29
  select("hubstats_users.id as user_id")
30
30
  .select("IFNULL(COUNT(DISTINCT hubstats_pull_requests.id),0) AS pull_request_count")
31
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.created_at > '#{time}' AND hubstats_pull_requests.repo_id = '#{repo_id}' AND hubstats_pull_requests.merged = '1'")
31
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.created_at BETWEEN ? AND ?)", start_date, end_date]))
32
+ .where("hubstats_pull_requests.repo_id = ? AND hubstats_pull_requests.merged = '1'", repo_id)
32
33
  .group("hubstats_users.id")
33
34
  }
34
35
 
35
- scope :comments_count_by_repo, lambda {|time,repo_id|
36
+ scope :comments_count_by_repo, lambda {|start_date, end_date, repo_id|
36
37
  select("hubstats_users.id as user_id")
37
38
  .select("COUNT(DISTINCT hubstats_comments.id) AS comment_count")
38
- .joins("LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND hubstats_comments.created_at > '#{time}' AND hubstats_comments.repo_id = '#{repo_id}'")
39
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND (hubstats_comments.created_at BETWEEN ? AND ?)", start_date, end_date]))
40
+ .where("hubstats_comments.repo_id = ?", repo_id)
39
41
  .group("hubstats_users.id")
40
42
  }
41
43
 
42
- scope :pulls_reviewed_count, lambda { |time|
44
+ scope :pulls_reviewed_count, lambda {|start_date, end_date|
43
45
  select("hubstats_users.id as user_id")
44
46
  .select("COUNT(DISTINCT hubstats_pull_requests.id) as reviews_count")
45
- .joins("LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND hubstats_comments.created_at > '#{time}'")
46
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.id = hubstats_comments.pull_request_id AND hubstats_pull_requests.closed_at > '#{time}'")
47
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_comments ON hubstats_comments.user_id = hubstats_users.id AND (hubstats_comments.created_at BETWEEN ? AND ?)", start_date, end_date]))
48
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.id = hubstats_comments.pull_request_id AND (hubstats_pull_requests.closed_at BETWEEN ? AND ?)", start_date, end_date]))
47
49
  .where("hubstats_pull_requests.user_id != hubstats_users.id")
48
50
  .group("hubstats_users.id")
49
51
  }
50
52
 
51
- scope :net_additions_count, lambda { |time|
53
+ scope :net_additions_count, lambda {|start_date, end_date|
52
54
  select("hubstats_users.id as user_id")
53
55
  .select("SUM(IFNULL(hubstats_pull_requests.additions, 0)) AS additions")
54
56
  .select("SUM(IFNULL(hubstats_pull_requests.deletions, 0)) AS deletions")
55
- .joins("LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND hubstats_pull_requests.created_at > '#{time}' AND hubstats_pull_requests.merged = '1'")
57
+ .joins(sanitize_sql_array(["LEFT JOIN hubstats_pull_requests ON hubstats_pull_requests.user_id = hubstats_users.id AND (hubstats_pull_requests.created_at BETWEEN ? AND ?) AND hubstats_pull_requests.merged = '1'", start_date, end_date]))
56
58
  .group("hubstats_users.id")
57
59
  }
58
60
 
59
- scope :pull_and_comment_count, lambda { |time|
61
+ scope :pull_and_comment_count, lambda {|start_date, end_date|
60
62
  select("hubstats_users.*, pull_request_count, comment_count")
61
- .joins("LEFT JOIN (#{pull_requests_count(time).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
62
- .joins("LEFT JOIN (#{comments_count(time).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
63
+ .joins("LEFT JOIN (#{pull_requests_count(start_date, end_date).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
64
+ .joins("LEFT JOIN (#{comments_count(start_date, end_date).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
63
65
  .group("hubstats_users.id")
64
66
  }
65
67
 
66
- scope :pull_and_comment_count_by_repo, lambda { |time,repo_id|
68
+ scope :pull_and_comment_count_by_repo, lambda {|start_date, end_date, repo_id|
67
69
  select("hubstats_users.*, pull_request_count, comment_count")
68
- .joins("LEFT JOIN (#{pull_requests_count_by_repo(time,repo_id).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
69
- .joins("LEFT JOIN (#{comments_count_by_repo(time,repo_id).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
70
+ .joins("LEFT JOIN (#{pull_requests_count_by_repo(start_date, end_date, repo_id).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
71
+ .joins("LEFT JOIN (#{comments_count_by_repo(start_date, end_date, repo_id).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
70
72
  .group("hubstats_users.id")
71
73
  }
72
- scope :with_all_metrics, lambda { |time|
74
+
75
+ scope :with_all_metrics, lambda {|start_date, end_date|
73
76
  select("hubstats_users.*, deploy_count, pull_request_count, comment_count, additions, deletions")
74
- .joins("LEFT JOIN (#{net_additions_count(time).to_sql}) AS net_additions ON net_additions.user_id = hubstats_users.id")
75
- .joins("LEFT JOIN (#{pull_requests_count(time).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
76
- .joins("LEFT JOIN (#{comments_count(time).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
77
- .joins("LEFT JOIN (#{deploys_count(time).to_sql}) AS deploys ON deploys.user_id = hubstats_users.id")
77
+ .joins("LEFT JOIN (#{net_additions_count(start_date, end_date).to_sql}) AS net_additions ON net_additions.user_id = hubstats_users.id")
78
+ .joins("LEFT JOIN (#{pull_requests_count(start_date, end_date).to_sql}) AS pull_requests ON pull_requests.user_id = hubstats_users.id")
79
+ .joins("LEFT JOIN (#{comments_count(start_date, end_date).to_sql}) AS comments ON comments.user_id = hubstats_users.id")
80
+ .joins("LEFT JOIN (#{deploys_count(start_date, end_date).to_sql}) AS deploys ON deploys.user_id = hubstats_users.id")
78
81
  .group("hubstats_users.id")
79
82
  }
80
83
 
@@ -103,11 +106,11 @@ module Hubstats
103
106
  Rails.logger.warn user.errors.inspect
104
107
  end
105
108
 
106
- def self.with_pulls_or_comments(time, repo_id = nil)
109
+ def self.with_pulls_or_comments(start_date, end_date, repo_id = nil)
107
110
  if repo_id
108
- pull_and_comment_count_by_repo(time,repo_id).weighted_sort
111
+ pull_and_comment_count_by_repo(start_date, end_date, repo_id).weighted_sort
109
112
  else
110
- pull_and_comment_count(time).weighted_sort
113
+ pull_and_comment_count(start_date, end_date).weighted_sort
111
114
  end
112
115
  end
113
116
 
@@ -24,12 +24,14 @@
24
24
  <%= link_to "Users", users_path%></li>
25
25
  <li>
26
26
  <select class="form-control push-down" id="time-select">
27
- <% Hubstats::TIMESPAN_ARRAY.each do |timespan| %>
28
- <option value=<%= timespan[:date] %>><%=timespan[:display_value]%></option>
27
+ <% Hubstats::DATE_RANGE_ARRAY.each do |date| %>
28
+ <option value=<%= date[:date] %>><%=date[:display_value]%></option>
29
29
  <% end %>
30
30
  </select>
31
31
  </li>
32
32
  </ul>
33
+ <!-- Start time: <%=@start_date%>
34
+ End time: <%=@end_date%> -->
33
35
  </div>
34
36
  </div>
35
37
  </nav>
@@ -7,6 +7,7 @@
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
+
10
11
  <%= render 'hubstats/partials/header' %>
11
12
  <%= yield %>
12
13
 
data/date_range ADDED
File without changes
data/hubstats.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency "rails", "~> 3.2.18"
20
20
  s.add_dependency "octokit", "~> 3.2"
21
21
  s.add_dependency "will_paginate-bootstrap"
22
+ s.add_dependency "bootstrap-datepicker"
22
23
  s.add_dependency "select2-rails", "3.5.9"
23
24
 
24
25
  s.add_development_dependency "rspec-rails",'~> 3.0.0.beta'
data/lib/hubstats.rb CHANGED
@@ -8,7 +8,7 @@ require "hubstats/config"
8
8
 
9
9
  module Hubstats
10
10
 
11
- TIMESPAN_ARRAY = [
11
+ DATE_RANGE_ARRAY = [
12
12
  {
13
13
  display_value: "Today",
14
14
  date: 1.day
@@ -1,3 +1,3 @@
1
1
  module Hubstats
2
- VERSION = "0.3.13"
2
+ VERSION = "0.3.14"
3
3
  end
@@ -24,7 +24,7 @@ module Hubstats
24
24
  :deployed_at => "2011-02-03 03:00:00 -0500",
25
25
  :user_id => nil)
26
26
  deploys_ordered = [deploy2, deploy3, deploy1]
27
- expect(Hubstats::Deploy).to receive_message_chain("group_by.order_with_timespan.paginate").and_return(deploys_ordered)
27
+ expect(Hubstats::Deploy).to receive_message_chain("group_by.order_with_date_range.paginate").and_return(deploys_ordered)
28
28
  get :index
29
29
  expect(response).to have_http_status(200)
30
30
  expect(response).to render_template(:index)
@@ -31,13 +31,14 @@ module Hubstats
31
31
  pull = create(:pull_request, :user => user,
32
32
  :repo => repo,
33
33
  :deploy_id => 404040)
34
- comment1 = create(:comment, :pull_request_id => pull.id)
35
- comment2 = create(:comment, :pull_request_id => pull.id)
36
- comment3 = create(:comment, :pull_request_id => pull.id)
34
+ comment1 = create(:comment, :pull_request_id => pull.id, :created_at => "2015-06-16")
35
+ comment2 = create(:comment, :pull_request_id => pull.id, :created_at => "2015-06-16")
36
+ comment3 = create(:comment, :pull_request_id => pull.id, :created_at => "2015-06-16")
37
37
  get :show, repo: repo, id: pull.id
38
38
  expect(assigns(:pull_request)).to eq(pull)
39
39
  expect(assigns(:pull_request).repo_id).to eq(101010)
40
40
  expect(assigns(:pull_request).deploy_id).to eq(404040)
41
+ # Below test could potentially fail if the date range changes
41
42
  expect(assigns(:comments)).to contain_exactly(comment1, comment2, comment3)
42
43
  expect(assigns(:pull_request).user_id).to eq(user.id)
43
44
  end
@@ -8,17 +8,22 @@ module Hubstats
8
8
  it "should list all of the repos" do
9
9
  repo1 = create(:repo, :id => 101010,
10
10
  :name => "silly",
11
- :full_name => "sportngin/silly")
11
+ :full_name => "sportngin/silly",
12
+ :updated_at => "2015-06-16")
12
13
  repo2 = create(:repo, :id => 202020,
13
14
  :name => "funny",
14
- :full_name => "sportngin/funny")
15
+ :full_name => "sportngin/funny",
16
+ :updated_at => "2015-06-16")
15
17
  repo3 = create(:repo, :id => 303030,
16
18
  :name => "loosey",
17
- :full_name => "sportngin/loosey")
19
+ :full_name => "sportngin/loosey",
20
+ :updated_at => "2015-06-16")
18
21
  repo4 = create(:repo, :id => 404040,
19
22
  :name => "goosey",
20
- :full_name => "sportngin/goosey")
23
+ :full_name => "sportngin/goosey",
24
+ :updated_at => "2015-06-16")
21
25
  get :index
26
+ # Below test could potentially fail if the date range changes
22
27
  expect(assigns(:repos)).to contain_exactly(repo2, repo1, repo3, repo4)
23
28
  end
24
29
  end
@@ -16,7 +16,7 @@ module Hubstats
16
16
  expect(deploy.user_id).to eq(202020)
17
17
  end
18
18
 
19
- it 'should order deploys based on timespan ASC' do
19
+ it 'should order deploys based on date range ASC' do
20
20
  repo = build(:repo)
21
21
  deploy1 = Deploy.create(git_revision: "c1a2b37",
22
22
  repo_id: repo.id,
@@ -28,19 +28,19 @@ module Hubstats
28
28
  user_id: 202020)
29
29
  deploy3 = Deploy.create(git_revision: "k10d8as",
30
30
  repo_id: repo.id,
31
- deployed_at: "2015-08-21 12:00:00",
31
+ deployed_at: "2015-03-21 12:00:00",
32
32
  user_id: 202020)
33
33
  deploy4 = Deploy.create(git_revision: "917d9ss",
34
34
  repo_id: repo.id,
35
35
  deployed_at: "2014-12-19 08:00:00",
36
36
  user_id: 202020)
37
37
  deploys_ordered = [deploy1, deploy2, deploy4, deploy3]
38
- new_ordered_deploys = Deploy.order_with_timespan(520.weeks, "ASC")
38
+ new_ordered_deploys = Deploy.order_with_date_range("2005-07-01", "2015-06-19", "ASC")
39
39
  expect(Deploy.count).to eq(4)
40
40
  expect(new_ordered_deploys).to eq(deploys_ordered)
41
41
  end
42
42
 
43
- it 'should order deploys based on timespan DESC' do
43
+ it 'should order deploys based on date range DESC' do
44
44
  repo = build(:repo)
45
45
  deploy1 = Deploy.create(git_revision: "c1a2b37",
46
46
  repo_id: repo.id,
@@ -52,14 +52,14 @@ module Hubstats
52
52
  user_id: 202020)
53
53
  deploy3 = Deploy.create(git_revision: "k10d8as",
54
54
  repo_id: repo.id,
55
- deployed_at: "2015-08-21 12:00:00",
55
+ deployed_at: "2015-03-21 12:00:00",
56
56
  user_id: 202020)
57
57
  deploy4 = Deploy.create(git_revision: "917d9ss",
58
58
  repo_id: repo.id,
59
59
  deployed_at: "2014-12-19 08:00:00",
60
60
  user_id: 202020)
61
61
  deploys_ordered = [deploy3, deploy4, deploy2, deploy1]
62
- new_ordered_deploys = Deploy.order_with_timespan(520.weeks, "DESC")
62
+ new_ordered_deploys = Deploy.order_with_date_range("2005-07-01", "2015-06-19", "DESC")
63
63
  expect(Deploy.count).to eq(4)
64
64
  expect(new_ordered_deploys).to eq(deploys_ordered)
65
65
  end
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,7 @@ require 'faker'
11
11
  # run twice. It is recommended that you do not name files matching this glob to
12
12
  # end with _spec.rb. You can configure this pattern with with the --pattern
13
13
  # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
14
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
14
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f }
15
15
 
16
16
  RSpec.configure do |config|
17
17
  # ## Mock Framework
data/test/test_helper.rb CHANGED
@@ -7,7 +7,7 @@ require "rails/test_help"
7
7
  Rails.backtrace_cleaner.remove_silencers!
8
8
 
9
9
  # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
11
11
 
12
12
  # Load fixtures from the engine
13
13
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Hursh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-18 00:00:00.000000000 Z
12
+ date: 2015-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: bootstrap-datepicker
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: select2-rails
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -215,6 +229,7 @@ files:
215
229
  - app/views/hubstats/users/show.html.erb
216
230
  - app/views/layouts/hubstats/application.html.erb
217
231
  - config/routes.rb
232
+ - date_range
218
233
  - db/migrate/20140604130339_create_hubstats_pull_requests.rb
219
234
  - db/migrate/20140604130457_create_hubstats_users.rb
220
235
  - db/migrate/20140604130504_create_hubstats_comments.rb