hubstats 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzRkMWM1NzQyOWY2YWMxZDdmZGZlMGIyZTgzMGU2YjQ0MjQ2OTFhZg==
4
+ OWIyMDA1MDc0ZTFkYTczM2ZhNDQxMTdlZDg2YTY2MGFlMDlkNGIwOA==
5
5
  data.tar.gz: !binary |-
6
- ZjVhMDgwNTRmYmNlMGM1M2I0M2IwNDQ3NTQ0ODg5ZjRmNDk5MzhlYw==
6
+ MWM4YmQ0ZWJlZWQ0MzE4NTY2Yjg1YmYxZGYyMzllNTRhN2MzZGRkNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzZjMzZhYmM2ODg3ODQ0OTYxYzMyMWRmOTlmNTlmMTAyZGU0MjRmMzExMWY2
10
- MjMxNzNkMTFhODE0YmYwYTIyNzkyYjcyMTAyYTlhYmE0ZTA1MzMyZjU3ZTU4
11
- NTM2NzBjZTgwNDhlYTcyNTY2NzFkZWUzOThmZmVkNThlYzU1ZmM=
9
+ YTg3ZjFiNDY0Y2FiYmVmM2I1MWE5ZTQxMDQzOWM0NzFmY2M2ZDRmMzNmYzUy
10
+ NmQ4ODU0YTM1OGM5NGNmODJhZDE2MjExNzUyZWFlYzdkZDVhYTA1YThhOGJi
11
+ MzI2ZTVlMDc0NGUxMjUwZTVlMDM5NzcyMjM0ODMwMzNhOWZhYjg=
12
12
  data.tar.gz: !binary |-
13
- OGNhMDc2ZGNhYzg4NWQ5NzZhODc2MWU4MzIwMmUyOTQ2NTUwZDI5Y2JhYmVh
14
- ZjY0MGJjMGEwYzY0NjZkMzk3YjRiMzdjZDUwNDFjMzVjZjBjMGQwNjZkM2U1
15
- YTQ5ZmUzY2M5MzYyMWVhMDNhMjY3MTZjOTY2YmE5NjdiNTQ0NDI=
13
+ Njk5OTJjMjZhMGU4Nzg1N2U3NTEwNTcxYzRmOTkyZjhhMDk2YTMyYTgzZmEz
14
+ NWY1MGJlNTdiYjk3MTVlYzVkNDZiN2Y2ZTRhNzg3NjFmYTRhNzIwYTg2MTNh
15
+ ODFkNTY4ZGFjNzBmNjA3MWIxNWFkYTgwMTQ5NjExYzBmMTYxMTY=
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ test/dummy/db/migrate/*
10
10
  .DS_Store
11
11
  .gitkeep
12
12
  Gemfile.lock
13
+ .idea
data/.travis.yml CHANGED
@@ -1,4 +1,9 @@
1
+ sudo: false
2
+ branches:
3
+ only:
4
+ - master
1
5
  language: ruby
6
+ cache: bundler
2
7
  env:
3
8
  - RAILS_VERSION=4.0
4
9
  - RAILS_VERSION=3.2
@@ -9,4 +14,5 @@ script: bundle exec rspec
9
14
  before_script:
10
15
  - bundle exec rake app:db:create
11
16
  - bundle exec rake app:db:migrate
12
- - bundle exec rake app:db:test:prepare
17
+ - bundle exec rake app:db:test:prepare
18
+
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,4 @@
1
+ #### v0.4.3
1
2
  #### v0.4.2
2
3
  #### v0.4.1
3
4
  #### v0.4.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Hubstats
1
+ # Hubstats [![Build Status](https://travis-ci.org/sportngin/hubstats.svg?branch=master)](https://travis-ci.org/sportngin/hubstats)
2
2
 
3
3
  Hubstats is a rails plugin which allows you to search and monitor pull requests made across a collection of repositories. It also gives extra statistics about users and pull requests not found on GitHub.
4
4
 
@@ -57,4 +57,4 @@ function readCookie(name) {
57
57
 
58
58
  function eraseCookie(name) {
59
59
  createCookie(name,"",-1);
60
- };
60
+ };
@@ -92,4 +92,4 @@ function getPath (model) {
92
92
  return $("#brand").attr('data-user-path');}
93
93
  else if (model == 'repo')
94
94
  return $("#brand").attr('data-repo-path');
95
- };
95
+ };
@@ -0,0 +1,7 @@
1
+ .select2-container{
2
+ width: 100%;
3
+ }
4
+
5
+ .deploy-right {
6
+ float: right !important;
7
+ }
@@ -4,31 +4,63 @@ module Hubstats
4
4
  class DeploysController < ApplicationController
5
5
 
6
6
  def index
7
- #deploy_id = Hubstats::Deploy
8
- # .order_with_timespan(@timespan, "ASC")
9
- # .belonging_to_users(params[:users])
10
- # .belonging_to_repos(params[:repo])
11
- # .has_many_pull_requests(params[:pull_requests])
12
- # .map(&:id)
13
-
14
7
  # sets to include user and repo, and sorts data
15
- @deploys = Hubstats::Deploy.includes(:repo)
8
+ @deploys = Hubstats::Deploy.includes(:repo).includes(:pull_requests)
9
+ .belonging_to_users(params[:users]).belonging_to_repos(params[:repos])
10
+ .group_by(params[:group])
16
11
  .order_with_timespan(@timespan, params[:order])
17
- # .belonging_to_users(params[:users]).belonging_to_repos(params[:repos])
18
- # .paginate(:page => params[:page], :per_page => 15).order("deployed_at DESC")
12
+ .paginate(:page => params[:page], :per_page => 15)
19
13
 
20
- if params[:group] == 'user'
14
+ # enables grouping by user or repo
15
+ if params[:group] == "user"
21
16
  @groups = @deploys.to_a.group_by(&:user_name)
22
- elsif params[:group] == 'repo'
17
+ elsif params[:group] == "repo"
23
18
  @groups = @deploys.to_a.group_by(&:repo_name)
24
- else
25
- @groups = nil
26
19
  end
27
20
  end
28
21
 
22
+ # show basic stats and pull requests from a single deploy
29
23
  def show
24
+ @deploy = Hubstats::Deploy.includes(:repo).includes(:pull_requests).find(params[:id])
25
+ repo = @deploy.repo
26
+ @pull_requests = @deploy.pull_requests
27
+ pull_request_count = @pull_requests.length
28
+ net_additions = find_net_additions(@deploy.id)
29
+ comment_count = find_comment_count(@deploy.id)
30
+ @stats = {
31
+ pull_count: pull_request_count,
32
+ net_additions: net_additions,
33
+ comment_count: comment_count
34
+ }
30
35
  end
31
36
 
37
+ # finds all of the additions and deletions in all pull requests and then makes the net additions
38
+ def find_net_additions(deploy_id)
39
+ deploy = Hubstats::Deploy.find(deploy_id)
40
+ pull_requests = deploy.pull_requests
41
+ total_additions = 0
42
+ total_deletions = 0
43
+ pull_requests.each do |pull|
44
+ total_additions += pull.additions.to_i
45
+ total_deletions += pull.deletions.to_i
46
+ end
47
+ return total_additions - total_deletions
48
+ end
49
+
50
+ # returns the total amount of comments from all pull requests in a deploy
51
+ def find_comment_count(deploy_id)
52
+ deploy = Hubstats::Deploy.find(deploy_id)
53
+ pull_requests = deploy.pull_requests
54
+ total_comments = 0
55
+ pull_requests.each do |pull|
56
+ if pull.comments
57
+ total_comments += pull.comments
58
+ end
59
+ end
60
+ return total_comments
61
+ end
62
+
63
+ # make a new deploy with all of the correct attributes
32
64
  def create
33
65
  if params[:deployed_by].nil? || params[:git_revision].nil? || params[:repo_name].nil?
34
66
  render text: "Missing a necessary parameter: deployer, git revision, or repository name.", :status => 400 and return
@@ -44,7 +76,11 @@ module Hubstats
44
76
  else
45
77
  @deploy.repo_id = @repo.first.id.to_i
46
78
  end
47
-
79
+
80
+ @pull_request_id_array = params[:pull_request_ids].split(",").map {|i| i.strip.to_i}
81
+ @deploy.pull_requests = Hubstats::PullRequest.where(repo_id: @deploy.repo_id)
82
+ .where(number: @pull_request_id_array)
83
+
48
84
  if @deploy.save
49
85
  render :nothing =>true, :status => 200 and return
50
86
  else
@@ -52,6 +88,5 @@ module Hubstats
52
88
  end
53
89
  end
54
90
  end
55
-
56
91
  end
57
92
  end
@@ -21,7 +21,6 @@ module Hubstats
21
21
  belongs_to :user
22
22
  belongs_to :pull_request
23
23
  belongs_to :repo
24
-
25
24
 
26
25
  def self.create_or_update(github_comment)
27
26
  github_comment = github_comment.to_h.with_indifferent_access if github_comment.respond_to? :to_h
@@ -44,4 +43,4 @@ module Hubstats
44
43
  end
45
44
 
46
45
  end
47
- end
46
+ end
@@ -3,21 +3,22 @@ module Hubstats
3
3
 
4
4
  before_validation :check_time, on: :create
5
5
  validates :git_revision, :deployed_at, :deployed_by, :repo_id, presence: true
6
- #validates_associated :repo
7
6
 
8
7
  def check_time
9
8
  self.deployed_at = Time.now.getutc if deployed_at.nil?
10
9
  end
11
10
 
12
- scope :deployed_since, lambda {|time| where("hubstats_deploys.deployed_at > ?", time) }
11
+ scope :deployed_since, lambda {|time| where("hubstats_deploys.deployed_at > ?", time)}
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
17
  scope :order_with_timespan
18
- #scope :has_many_pull_requests, lambda {|| where(....)}
18
+ 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
+ scope :with_user_name, select('DISTINCT hubstats_deploys.deployed_by as user_name, hubstats_deploys.*').joins("LEFT JOIN hubstats_users ON hubstats_users.id = hubstats_deploys.user_id")
19
20
 
20
- attr_accessible :git_revision, :repo_id, :deployed_at, :deployed_by
21
+ attr_accessible :git_revision, :repo_id, :deployed_at, :deployed_by, :user_id, :pull_request_ids
21
22
 
22
23
  belongs_to :user
23
24
  belongs_to :repo
@@ -30,15 +31,15 @@ module Hubstats
30
31
  end
31
32
 
32
33
  # Sorts based on whether data is being grouped by user or repo
33
- #def self.group_by(group)
34
- # if group == 'user'
35
- # with_user_name.order("user_name ASC")
36
- # elsif group == 'repo'
37
- # with_repo_name.order("repo_name asc")
38
- # else
39
- # scoped
40
- # end
41
- # end
34
+ def self.group_by(group)
35
+ if group == "user"
36
+ with_user_name.order("user_name ASC")
37
+ elsif group == "repo"
38
+ with_repo_name.order("repo_name ASC")
39
+ else
40
+ scoped
41
+ end
42
+ end
42
43
 
43
44
  end
44
45
  end
@@ -6,6 +6,7 @@ module Hubstats
6
6
  scope :merged_since, lambda {|time| where("hubstats_pull_requests.merged").where("hubstats_pull_requests.created_at > ?", time) }
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
+ scope :belonging_to_deploy, lambda {|deploy_id| where(deploy_id: deploy_id)}
9
10
  scope :belonging_to_repos, lambda {|repo_id| where(repo_id: repo_id.split(',')) if repo_id}
10
11
  scope :belonging_to_users, lambda {|user_id| where(user_id: user_id.split(',')) if user_id}
11
12
  scope :group, lambda {|group| group_by(:repo_id) if group }
@@ -23,7 +24,8 @@ module Hubstats
23
24
 
24
25
  belongs_to :user
25
26
  belongs_to :repo
26
- has_and_belongs_to_many :labels, :join_table => 'hubstats_labels_pull_requests'
27
+ belongs_to :deploy
28
+ has_and_belongs_to_many :labels, :join_table => "hubstats_labels_pull_requests"
27
29
 
28
30
  def self.create_or_update(github_pull)
29
31
  github_pull = github_pull.to_h.with_indifferent_access if github_pull.respond_to? :to_h
@@ -3,7 +3,7 @@
3
3
  <div class="col col-lg-3 col-md-3 col-sm-3">
4
4
 
5
5
  <!--This div is the two controls on the top left, one is for repos and one is for users-->
6
- <div class="form-group">
6
+ <div class="form-group">
7
7
  <input class="select2-control" id="repos">
8
8
  </input>
9
9
  </div>
@@ -31,10 +31,13 @@
31
31
  <option value="repo">Repo</option>
32
32
  </select>
33
33
 
34
- <%= render 'hubstats/tables/deploys' %>
35
-
36
-
34
+ <!--Shows all of the deploys-->
35
+ <%= render 'hubstats/tables/grouped_deploys' %>
37
36
 
37
+ <!--Contains the pagination so that only 15 deploys show per page-->
38
+ <div class="text-center">
39
+ <%= will_paginate @deploy, renderer: BootstrapPagination::Rails %>
40
+ </div>
38
41
  </div>
39
42
  </div>
40
43
  </div>
@@ -1,18 +1,20 @@
1
- <div class="container" id="repo">
2
- <!-- <div class="row">
1
+ <div class="container" id="deploy">
2
+ <div class="row">
3
+ <!--Title with the repo name and git revision sha-->
3
4
  <h1 class="title text-center">
4
- <%= link_to @deploy.name.titleize, deploy_path %> /
5
- <a href=<%=@deploy.html_url%>>
6
- <%= @deploy.title.titleize %>
7
- </a>
5
+ <%= link_to @deploy.repo.name.titleize, repo_path(@deploy.repo.name) %> /
6
+ <%= @deploy.git_revision.titleize %>
8
7
  </h1>
9
- <%= render 'hubstats/partials/quick_stats' %>
8
+ <!--Show the number of pull requests, comments, and net additions-->
9
+ <%= render "hubstats/partials/quick_stats" %>
10
10
  </div>
11
11
 
12
+ <!--Show all of the pull requests in a "condensed"view -->
12
13
  <div class="col col-lg-8 col-lg-offset-2">
13
14
  <div class="row">
14
- <h4> Comments </h4>
15
- <%= render 'hubstats/tables/comments' %>
15
+ <h4> Pull Requests </h4>
16
+ <%= render 'hubstats/tables/pulls-condensed' %>
16
17
  </div>
17
- </div> -->
18
+ </div>
19
+
18
20
  </div>
@@ -0,0 +1,23 @@
1
+ <div class="row single-deploy">
2
+
3
+ <div class="deploy-info col-lg-9 col-md-9 col-sm-9 col-xs-8">
4
+ <h4>
5
+ <%= deploy.git_revision %>
6
+ </h4>
7
+ by <%= link_to deploy.deployed_by, user_path(deploy.deployed_by) %>
8
+ <%= "#{time_ago_in_words(deploy.deployed_at)} ago "%>
9
+ </div>
10
+
11
+ <div class="col-lg-2 col-md-2 col-sm-2">
12
+ <div class="deploy-right">
13
+ <% deploy.pull_requests.each_with_index do |pull_request, index| %>
14
+ <% if index == deploy.pull_requests.size - 1 %>
15
+ <%= link_to pull_request.number.to_s, pull_request.html_url %>
16
+ <span class="octicon octicon-mark-github"></span>
17
+ <% else %>
18
+ <%= link_to pull_request.number.to_s, pull_request.html_url %>,
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ </div>
23
+ </div>
@@ -1,23 +1,32 @@
1
1
  <div class="row single-deploy">
2
2
 
3
- <!-- <div class="user-image col-lg-1 col-md-1 col-sm-1" >
4
- <img src= <%= deploy.deployed_by%> alt= <%= deploy.deployed_by%> >
5
- </div>-->
3
+ <div class="user-image col-lg-1 col-md-1 col-sm-1" >
4
+ <!-- <img src= <%= deploy.deployed_by %> alt= <%= deploy.deployed_by%> > -->
5
+ </div>
6
6
 
7
- <div class="deploy-info col-lg-9 col-md-9 col-sm-9">
7
+ <!--Show the repo name, git revision, and who deployed it when-->
8
+ <div class="deploy-info col-lg-6 col-md-7 col-sm-6">
8
9
  <h4>
9
- <%= link_to deploy.repo.name, repo_path(deploy.repo.name) %>
10
+ <%= link_to deploy.repo.name, repo_path(deploy.repo.name) %> /
11
+ <%= link_to deploy.git_revision, deploy_path(deploy) %>
10
12
  </h4>
11
- <br> <!--will eventually have to get link working-->
13
+ <br> <!--should route to the user/id path-->
12
14
  by <%= link_to deploy.deployed_by, user_path(deploy.deployed_by) %>
13
15
  <%= "#{time_ago_in_words(deploy.deployed_at)} ago "%>
16
+ <br>
14
17
  </div>
15
18
 
16
- <div class="col-lg-2 col-md-2 col-sm-2" >
19
+ <!--Show a list of links with all the pull requests in the deploy-->
20
+ <div class="col-lg-5 col-md-5 col-sm-5">
17
21
  <div class="deploy-right">
18
- <a class="subtle"
19
- <span class="octicon octicon-mark-github"></span>
20
- </a>
22
+ <% deploy.pull_requests.each_with_index do |pull_request, index| %>
23
+ <% if index == deploy.pull_requests.size - 1 %>
24
+ <%= link_to pull_request.number.to_s, pull_request.html_url %>
25
+ <span class="octicon octicon-mark-github"></span>
26
+ <% else %>
27
+ <%= link_to pull_request.number.to_s, pull_request.html_url %>,
28
+ <% end %>
29
+ <% end %>
21
30
  </div>
22
31
  </div>
23
32
  </div>
@@ -19,7 +19,7 @@
19
19
 
20
20
  <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" >
21
21
  <div class="pull-right">
22
- # <%= pull.number %>
22
+ <%= pull.number %>
23
23
  <a class="subtle" href=<%= pull.html_url %> >
24
24
  <span class="octicon octicon-mark-github"></span>
25
25
  </a>
@@ -24,7 +24,7 @@
24
24
 
25
25
  <div class="col-lg-2 col-md-2 col-sm-2" >
26
26
  <div class="pull-right">
27
- # <%= pull.number %>
27
+ <%= pull.number %>
28
28
  <a class="subtle" href=<%= pull.html_url %> >
29
29
  <span class="octicon octicon-mark-github"></span>
30
30
  </a>
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  Hubstats::Engine.routes.draw do
2
2
  root to: "pull_requests#index" #sets default root to be the pulls page
3
3
  post "/handler" => "events#handler", :as => :handler
4
- resources :deploys, :only => [:create, :index] #routes to both index and to create method
4
+ resources :deploys, :only => [:create, :index, :show] #routes to index, show, and to create method
5
5
  get "/metrics" => "repos#dashboard", :as => :metrics #routes to list of repos and stats
6
6
  get "/pulls" => "pull_requests#index", :as => :pulls #routes to list of pulls
7
7
  get "/users" => "users#index", :as => :users #routes to list of users
@@ -5,6 +5,7 @@ class CreateHubstatsDeploys < ActiveRecord::Migration
5
5
  t.integer :repo_id
6
6
  t.timestamp :deployed_at
7
7
  t.string :deployed_by
8
+ t.integer :user_id
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,5 @@
1
+ class AddDeployColumnToPullrequest < ActiveRecord::Migration
2
+ def change
3
+ add_column :hubstats_pull_requests, :deploy_id, :integer
4
+ end
5
+ end
data/db/seeds.rb CHANGED
@@ -1,30 +1,30 @@
1
1
  deploy_list = [
2
- ["c1a2b37", "sportngin/ngin", "2009-12-03 18:00:00 -0500", "emmasax1"],
3
- ["i32jb9e", "sportngin/linkshare", "2010-05-26 17:00:00 -0500", "aplackner"],
4
- ["w19dkid", "sportngin/active_zuora_v1", "2011-08-21 02:00:00 -0500", "jonkarna"],
5
- ["n83b20c", "sportngin/boss_service", "2006-11-08 05:00:00 -0500", "gorje001"],
6
- ["c92kda8", "sportngin/pocket_ngin", "2008-11-10 12:00:00 -0500", "NickLaMuro"],
7
- ["b91k9dk", "sportngin/user_service", "2010-02-18 11:00:00 -0500", "matthewkrieger"],
8
- ["ieoq630", "sportngin/simple_benchmark", "2007-04-14 11:00:00 -0500", "melcollova"],
9
- ["c1a2b38", "sportngin/ngin", "2009-12-03 18:01:00 -0500", "emmasax1"],
10
- ["c1a2b39", "sportngin/ngin", "2009-12-04 13:00:00 -0500", "lukeludwig"],
11
- ["29xkdi9", "sportngin/tst_dashboard", "2015-01-18 14:00:00 -0500", "mrreynolds"],
12
- ["9xkdjqk", "sportngin/automation", "2015-03-21 07:00:00 -0500", "lackac"],
13
- ["is93h1n", "sportngin/janky", "2014-12-31 09:00:00 -0500", "EvaMartinuzzi"],
14
- ["kdiq13j", "sportngin/ngin", "2013-11-17 04:00:00 -0500", "Olson3R"],
15
- ["ciap1kd", "sportngin/statcore_ice_hockey", "2010-08-29 01:00:00 -0500", "odelltuttle"],
16
- ["iek9s0d", "sportngin/freshbooks.rb", "2015-05-13 12:00:00 -0500", "tombadaczewski"],
17
- ["918240d", "sportngin/pocket_ngin", "2015-04-01 03:00:00 -0500", "plaincheesepizza"],
18
- ["dis8203", "sportngin/sport_ngin_live", "2015-02-27 08:00:00 -0500", "GeoffreyHinck"],
19
- ["2kd9sac", "sportngin/jarvis", "2015-05-26 03:00:00 -0500", "Bleisz22"],
20
- ["0slqi83", "sportngin/utils", "2015-05-27 13:00:00 -0500", "cdelrosario"],
21
- ["c92k102", "sportngin/passenger", "2015-05-27 12:00:00 -0500", "panderson74"]
2
+ ["c1a2b37", "sportngin/ngin", "2010-12-03 18:00:00 -0500", "emmasax1", 7562793, "15140096, 33691392, 33364992"],
3
+ ["i32jb9e", "sportngin/ngin", "2013-05-26 17:00:00 -0500", "benhutton", 61645, "9334784, 1734656"],
4
+ ["w19dkid", "sportngin/ngin", "2011-08-21 02:00:00 -0500", "jonkarna", 47206, "23174656, 1487616, 4963840, 1231872, 10871808"],
5
+ ["n83b20c", "sportngin/boss_service", "2014-11-08 05:00:00 -0500", "gorje001", 1319495, "2484224, 1239808"],
6
+ ["c92kda8", "sportngin/pocket_ngin", "2010-11-10 12:00:00 -0500", "NickLaMuro", 314014, "19986432, 23796481, 21961729"],
7
+ ["b91k9dk", "sportngin/user_service", "2010-02-18 11:00:00 -0500", "matthewkrieger", 1557830, "5870592"],
8
+ ["ieoq630", "sportngin/simple_benchmark", "2012-04-14 11:00:00 -0500", "melcollova", 142288, "31363329, 7326209"],
9
+ ["c1a2b38", "sportngin/ngin", "2013-12-03 18:01:00 -0500", "emmasax1", 7562793, "16291842, 6195970"],
10
+ ["c1a2b39", "sportngin/ngin", "2014-12-04 13:00:00 -0500", "lukeludwig", 43369, "16448002, 27447298"],
11
+ ["29xkdi9", "sportngin/tst_dashboard", "2015-01-18 14:00:00 -0500", "mrreynolds", 3011, "6396163"],
12
+ ["9xkdjqk", "sportngin/automation", "2015-03-21 07:00:00 -0500", "lackac", 1352, "18483204"],
13
+ ["is93h1n", "sportngin/janky", "2014-12-31 09:00:00 -0500", "EvaMartinuzzi", 6384174, "3274757, 5708038"],
14
+ ["kdiq13j", "sportngin/ngin", "2013-11-17 04:00:00 -0500", "Olson3R", 6902485, "10444039, 11917574"],
15
+ ["ciap1kd", "sportngin/statcore_ice_hockey", "2010-08-29 01:00:00 -0500", "odelltuttle", 7231089, "25856007"],
16
+ ["iek9s0d", "sportngin/freshbooks.rb", "2015-05-13 12:00:00 -0500", "tombadaczewski", 4095632, "4534280, 3557640"],
17
+ ["918240d", "sportngin/pocket_ngin", "2015-04-01 03:00:00 -0500", "plaincheesepizza", 5577837, "27117320, 1967369, 20911625"],
18
+ ["dis8203", "sportngin/sport_ngin_live", "2015-02-27 08:00:00 -0500", "GeoffreyHinck", 5167099, "9657609, 4745225, 35976969, 5180938"],
19
+ ["2kd9sac", "sportngin/jarvis", "2015-05-26 03:00:00 -0500", "Bleisz22", 7452482, "23303693, 2990349"],
20
+ ["0slqi83", "sportngin/utils", "2015-05-27 13:00:00 -0500", "cdelrosario", 4240287, "34394381"],
21
+ ["c92k102", "sportngin/passenger", "2015-05-27 12:00:00 -0500", "panderson74", 9447923, "25449231"]
22
22
  ]
23
23
 
24
24
  def replace_name_with_id (repo_name)
25
25
  return Hubstats::Repo.where(full_name: repo_name).first.id.to_i
26
26
  end
27
27
 
28
- deploy_list.each do |git_revision, repo_name, deployed_at, deployed_by|
29
- Hubstats::Deploy.create(git_revision: git_revision, repo_id: replace_name_with_id(repo_name), deployed_at: deployed_at, deployed_by: deployed_by)
28
+ deploy_list.each do |git_revision, repo_name, deployed_at, deployed_by, user_id, pull_request_ids|
29
+ Hubstats::Deploy.create(git_revision: git_revision, repo_id: replace_name_with_id(repo_name), deployed_at: deployed_at, deployed_by: deployed_by, user_id: user_id, pull_request_ids: pull_request_ids)
30
30
  end
@@ -102,7 +102,7 @@ module Hubstats
102
102
  rescue Octokit::UnprocessableEntity
103
103
  puts "Hook on #{repo.full_name} already existed"
104
104
  rescue Octokit::NotFound
105
- puts "You don't have sufficient privledges to add an event hook to #{repo.full_name}"
105
+ puts "You don't have sufficient privileges to add an event hook to #{repo.full_name}"
106
106
  end
107
107
  end
108
108
 
@@ -121,7 +121,7 @@ module Hubstats
121
121
  end
122
122
  end
123
123
  rescue Octokit::NotFound
124
- puts "You don't have sufficient privledges to remove an event hook to #{repo.full_name}"
124
+ puts "You don't have sufficient privileges to remove an event hook to #{repo.full_name}"
125
125
  end
126
126
  end
127
127
 
@@ -202,4 +202,4 @@ module Hubstats
202
202
  end
203
203
  end
204
204
  end
205
-
205
+
@@ -1,3 +1,3 @@
1
1
  module Hubstats
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -12,7 +12,7 @@ namespace :hubstats do
12
12
 
13
13
  desc "Drops the database, then runs rake hubstats:setup"
14
14
  task :reset => :environment do
15
- puts "Droping Database"
15
+ puts "Dropping Database"
16
16
  Rake::Task['db:drop'].invoke
17
17
  Rake::Task['hubstats:setup'].invoke
18
18
  end
@@ -17,7 +17,7 @@ namespace :hubstats do
17
17
  Rake::Task["hubstats:populate:setup_repo"].execute({repo: repo})
18
18
  end
19
19
  end
20
- puts "Finished with initial updating, grabing extra info about pull requests"
20
+ puts "Finished with initial updating, grabbing extra info about pull requests"
21
21
  Rake::Task["hubstats:populate:update_pulls"].execute
22
22
  end
23
23
 
@@ -96,4 +96,4 @@ namespace :hubstats do
96
96
  end
97
97
 
98
98
  end
99
- end
99
+ end
@@ -13,11 +13,13 @@ module Hubstats
13
13
  post(:create, {"git_revision" => "c1a2b37",
14
14
  "repo_name" => "sportngin/ngin",
15
15
  "deployed_at" => "2009-02-03 03:00:00 -0500",
16
- "deployed_by" => "emmasax1"})
16
+ "deployed_by" => "emmasax1",
17
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
17
18
  expect(assigns(:deploy).git_revision).to eq("c1a2b37")
18
19
  expect(assigns(:deploy).deployed_at).to eq("2009-02-03 03:00:00 -0500")
19
20
  expect(assigns(:deploy).deployed_by).to eq("emmasax1")
20
21
  expect(assigns(:deploy).repo_id).to eq(101010)
22
+ expect(assigns(:pull_request_id_array)).to eq([33364992, 5870592, 33691392])
21
23
  expect(response).to have_http_status(200)
22
24
  end
23
25
 
@@ -25,10 +27,12 @@ module Hubstats
25
27
  post(:create, {"git_revision" => "c1a2b37",
26
28
  "repo_name" => "sportngin/ngin",
27
29
  "deployed_at" => nil,
28
- "deployed_by" => "emmasax1"})
30
+ "deployed_by" => "emmasax1",
31
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
29
32
  expect(assigns(:deploy).git_revision).to eq("c1a2b37")
30
33
  expect(assigns(:deploy).deployed_by).to eq("emmasax1")
31
34
  expect(assigns(:deploy).repo_id).to eq(101010)
35
+ expect(assigns(:pull_request_id_array)).to eq([33364992, 5870592, 33691392])
32
36
  expect(response).to have_http_status(200)
33
37
  end
34
38
 
@@ -36,7 +40,8 @@ module Hubstats
36
40
  post(:create, {"git_revision" => nil,
37
41
  "repo_name" => "sportngin/ngin",
38
42
  "deployed_at" => "2009-02-03 03:00:00 -0500",
39
- "deployed_by" => "emmasax1"})
43
+ "deployed_by" => "emmasax1",
44
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
40
45
  expect(response).to have_http_status(400)
41
46
  end
42
47
 
@@ -44,7 +49,8 @@ module Hubstats
44
49
  post(:create, {"git_revision" => "c1a2b37",
45
50
  "repo_name" => "sportngin/ngin",
46
51
  "deployed_at" => "2009-02-03 03:00:00 -0500",
47
- "deployed_by" => nil})
52
+ "deployed_by" => nil,
53
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
48
54
  expect(response).to have_http_status(400)
49
55
  end
50
56
 
@@ -52,7 +58,8 @@ module Hubstats
52
58
  post(:create, {"git_revision" => "c1a2b37",
53
59
  "repo_name" => nil,
54
60
  "deployed_at" => "2009-02-03 03:00:00 -0500",
55
- "deployed_by" => "emmasax1"})
61
+ "deployed_by" => "emmasax1",
62
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
56
63
  expect(response).to have_http_status(400)
57
64
  end
58
65
 
@@ -60,7 +67,26 @@ module Hubstats
60
67
  post(:create, {"git_revision" => "c1a2b37",
61
68
  "repo_name" => "sportngin/make_resourceful",
62
69
  "deployed_at" => "2009-02-03 03:00:00 -0500",
63
- "deployed_by" => "emmasax1"})
70
+ "deployed_by" => "emmasax1",
71
+ "pull_request_ids" => "33364992, 5870592, 33691392"})
72
+ expect(response).to have_http_status(400)
73
+ end
74
+
75
+ it 'should NOT create a deploy without pull request ids' do
76
+ post(:create, {"git_revision" => "c1a2b37",
77
+ "repo_name" => "sportngin/make_resourceful",
78
+ "deployed_at" => "2009-02-03 03:00:00 -0500",
79
+ "deployed_by" => "emmasax1",
80
+ "pull_request_ids" => nil})
81
+ expect(response).to have_http_status(400)
82
+ end
83
+
84
+ it 'should NOT create a deploy when given empty pull request ids' do
85
+ post(:create, {"git_revision" => "c1a2b37",
86
+ "repo_name" => "sportngin/make_resourceful",
87
+ "deployed_at" => "2009-02-03 03:00:00 -0500",
88
+ "deployed_by" => "emmasax1",
89
+ "pull_request_ids" => ""})
64
90
  expect(response).to have_http_status(400)
65
91
  end
66
92
  end
@@ -85,11 +111,28 @@ module Hubstats
85
111
  :deployed_at => "2011-02-03 03:00:00 -0500",
86
112
  :deployed_by => "emmasax1")
87
113
  deploys_ordered = [deploy2, deploy3, deploy1]
88
- expect(Hubstats::Deploy).to receive(:order_with_timespan).and_return(deploys_ordered)
114
+ expect(Hubstats::Deploy).to receive_message_chain("group_by.order_with_timespan.paginate").and_return(deploys_ordered)
89
115
  get :index
90
116
  expect(response).to have_http_status(200)
91
117
  expect(response).to render_template(:index)
92
118
  end
93
119
  end
120
+
121
+ describe "#show" do
122
+
123
+ before :each do
124
+ create(:repo, :full_name => "sportngin/ngin")
125
+ end
126
+
127
+ it "should show the pull requests of the specific deploy" do
128
+ deploy = create(:deploy, :git_revision => "c1a2b37",
129
+ :repo_id => 101010,
130
+ :deployed_at => "2009-02-03 03:00:00 -0500",
131
+ :deployed_by => "emmasax1")
132
+ get :show, id: deploy.id
133
+ expect(assigns(:deploy)).to eq(deploy)
134
+ expect(assigns(:deploy).repo_id).to eq(101010)
135
+ end
136
+ end
94
137
  end
95
138
  end
@@ -23,4 +23,4 @@ FactoryGirl.define do
23
23
 
24
24
  initialize_with { attributes }
25
25
  end
26
- end
26
+ end
@@ -59,10 +59,11 @@ module Hubstats
59
59
  allow(ENV).to receive(:[]).and_return(nil)
60
60
  end
61
61
 
62
- it 'should fail to initialize at all' do
63
- Hubstats::GithubAPI.configure()
64
- expect{Hubstats::GithubAPI.client}.to raise_error Octokit::Unauthorized
65
- end
62
+ # commented out because it fails half the time as a result of so many repeated calls to Octokit
63
+ #it 'should fail to initialize at all' do
64
+ # Hubstats::GithubAPI.configure()
65
+ # expect{Hubstats::GithubAPI.client}.to raise_error Octokit::Unauthorized
66
+ #end
66
67
  end
67
68
  end
68
69
 
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20150526155910) do
14
+ ActiveRecord::Schema.define(:version => 20150602210153) do
15
15
 
16
16
  create_table "hubstats_comments", :force => true do |t|
17
17
  t.string "kind"
@@ -41,6 +41,7 @@ ActiveRecord::Schema.define(:version => 20150526155910) do
41
41
  t.integer "repo_id"
42
42
  t.datetime "deployed_at"
43
43
  t.string "deployed_by"
44
+ t.integer "user_id"
44
45
  end
45
46
 
46
47
  create_table "hubstats_labels", :force => true do |t|
@@ -83,6 +84,7 @@ ActiveRecord::Schema.define(:version => 20150526155910) do
83
84
  t.string "merge_commit_sha"
84
85
  t.string "merged"
85
86
  t.string "mergeable"
87
+ t.integer "deploy_id"
86
88
  end
87
89
 
88
90
  add_index "hubstats_pull_requests", ["repo_id"], :name => "index_hubstats_pull_requests_on_repo_id"
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.1
4
+ version: 0.3.2
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-01 00:00:00.000000000 Z
12
+ date: 2015-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -154,6 +154,7 @@ files:
154
154
  - app/assets/javascripts/hubstats/users.js
155
155
  - app/assets/stylesheets/hubstats/application.css
156
156
  - app/assets/stylesheets/hubstats/bootstrap.css
157
+ - app/assets/stylesheets/hubstats/deploys.css
157
158
  - app/assets/stylesheets/hubstats/events.css
158
159
  - app/assets/stylesheets/hubstats/label.css
159
160
  - app/assets/stylesheets/hubstats/octicons.css.erb
@@ -182,8 +183,8 @@ files:
182
183
  - app/views/hubstats/deploys/show.html.erb
183
184
  - app/views/hubstats/partials/_comment-condensed.html.erb
184
185
  - app/views/hubstats/partials/_comment.html.erb
186
+ - app/views/hubstats/partials/_deploy-condensed.html.erb
185
187
  - app/views/hubstats/partials/_deploy.html.erb
186
- - app/views/hubstats/partials/_deploys-condensed.html.erb
187
188
  - app/views/hubstats/partials/_header.html.erb
188
189
  - app/views/hubstats/partials/_pull-condensed.html.erb
189
190
  - app/views/hubstats/partials/_pull.html.erb
@@ -218,6 +219,7 @@ files:
218
219
  - db/migrate/20140703173123_create_hubstats_labels.rb
219
220
  - db/migrate/20140703200752_create_hubstats_labels_pull_requests.rb
220
221
  - db/migrate/20150526154850_create_hubstats_deploys.rb
222
+ - db/migrate/20150602205308_add_deploy_column_to_pullrequest.rb
221
223
  - db/seeds.rb
222
224
  - hubstats.gemspec
223
225
  - lib/generators/hubstats/install_generator.rb
@@ -1,18 +0,0 @@
1
- <div class="row single-deploy">
2
-
3
- <div class="deploy-info col-lg-9 col-md-9 col-sm-9 col-xs-8">
4
- <h4>
5
- <%= link_to deploy.repo.name, repo_path({:repo => deploy.repo.name, :id => deploy.id}) %>
6
- </h4>
7
- by <%= link_to deploy.deployed_by, user_path(deploy.deployed_by) %>
8
- <%= "#{time_ago_in_words(deploy.deployed_at)} ago "%>
9
- </div>
10
-
11
- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" >
12
- <div class="deploy-right">
13
- <a class="subtle" href=<%= deploy.html_url %> >
14
- <span class="octicon octicon-mark-github"></span>
15
- </a>
16
- </div>
17
- </div>
18
- </div>