hub_store 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f4092b0d303f78da4c96c3b32c44fac4831007d65a12b1e9c3be9e110375902
4
- data.tar.gz: 37fe2b1198a8437ce5ea8fea1097203527d4e9625dbc14d2209c620537179768
3
+ metadata.gz: 6a563df0ec7313beaea07c489b97458c9598f43d4a2ec408a421fa1e8af98ec9
4
+ data.tar.gz: 853e8cbf787e7a406965a4b3c8566d17e17dfb67d2b2104bb1fdfeb6a691c7f8
5
5
  SHA512:
6
- metadata.gz: fca7fad9c5893ff4bab52d7f5e5e43412749faf11de0bd53270a4b704c341c78a4c38c88105383e3968c56b38692e05052b19a1ed48ee3c535a9ae4574819501
7
- data.tar.gz: 333e42cedaa64a3ee8374ad1b7831a5b275334d43fd81f3bb1e935b12e43db44ba3dfe2a053f78d71ff3363e3b2275a6a1dce0ef30385a8588fe9cf21bd32243
6
+ metadata.gz: 79b7350946f4fdb4acb5508df53a33f4f76baf6e172c8d79cad078807e4a276099d908e708738264512cd5f72b16c4563633ed21286e7e887062aa46b268ef33
7
+ data.tar.gz: 37163e98c43ede5aef32c78a3c0f026f2c6d2856140b5c34c808629975498457fc8064f15cfc26dc2cbece1353bea769c65a3e50980621da8ff5ba8bfdab28fb
data/README.md CHANGED
@@ -3,38 +3,17 @@
3
3
  Save raw pull request and review metadata from GitHub for metrics
4
4
  analysis etc.
5
5
 
6
-
7
6
  ## Usage
8
7
 
9
- ### Using inside an app
10
- Add this line to your application's Gemfile:
11
-
12
- ```ruby
13
- gem "hub_store"
14
- ```
15
-
16
- Then:
17
-
18
- ```ruby
19
- REPOS = "balvig/hub_store,balvig/hub_link"
20
-
21
- HubStore::Importer.new(repos: REPOS, start_date: 4.weeks.ago).run
22
- # => Imports pull request and review data to a local sqlite DB
23
-
24
- HubStore::Exporter.new(resource: PullRequest).run
25
- # => Exports pull request data from sqlite DB to `pull_requests.csv`
26
-
27
- HubStore::Exporter.new(resource: Review).run
28
- # => Exports review data from sqlite DB to `reviews.csv`
29
- ```
8
+ Running the following will export 2 years worth of PRs/Reviews to CSV
9
+ files.
30
10
 
31
- ### Using from command line
11
+ The gem will use an sqlite db as interim storage to allow resuming and
12
+ subsequent exports:
32
13
 
33
14
  ```bash
34
15
  gem install hub_store
35
- OCTOKIT_ACCESS_TOKEN=<token> hub_store <github_organization/repo_name>
36
- # Exports 2 years worth of PRs/Reviews to csv files.
37
- # Subsequent runs resume from last updated_at
16
+ OCTOKIT_ACCESS_TOKEN=<token> hub_store <github_organization/repo_names>
38
17
  ```
39
18
 
40
19
  ## Development
data/hub_store.gemspec CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency "activerecord"
33
33
  spec.add_dependency "dotenv"
34
- spec.add_dependency "hub_link"
34
+ spec.add_dependency "hub_link", ">= 0.4"
35
35
  spec.add_dependency "sqlite3"
36
36
  end
data/lib/hub_store/cli.rb CHANGED
@@ -17,12 +17,11 @@ module HubStore
17
17
 
18
18
  attr_reader :argv
19
19
 
20
- def start_date
21
- PullRequest.resume_date
22
- end
23
-
24
20
  def import_data
25
- Importer.new(repos: repo_names, start_date: start_date).run
21
+ repos.each do |repo|
22
+ start_date = PullRequest.for(repo).recently_updated_first.first&.updated_at
23
+ Importer.new(repo: repo, start_date: start_date).run
24
+ end
26
25
  end
27
26
 
28
27
  def export_csv
@@ -31,6 +30,10 @@ module HubStore
31
30
  end
32
31
  end
33
32
 
33
+ def repos
34
+ repo_names.split(",")
35
+ end
36
+
34
37
  def repo_names
35
38
  argv[0].presence || stop
36
39
  end
@@ -6,8 +6,8 @@ require "hub_store/review_request"
6
6
 
7
7
  module HubStore
8
8
  class Importer
9
- def initialize(repos:, start_date: nil)
10
- @repos = repos
9
+ def initialize(repo:, start_date: nil)
10
+ @repo = repo
11
11
  @start_date = start_date || 2.years.ago
12
12
  end
13
13
 
@@ -21,7 +21,7 @@ module HubStore
21
21
 
22
22
  private
23
23
 
24
- attr_reader :repos, :start_date
24
+ attr_reader :repo, :start_date
25
25
 
26
26
  def import_prs(batch)
27
27
  batch.pull_requests.each do |row|
@@ -52,7 +52,7 @@ module HubStore
52
52
  end
53
53
 
54
54
  def stream
55
- @_stream ||= HubLink::Stream.new(repos, start_date: start_date)
55
+ @_stream ||= HubLink::Stream.new(repo, start_date: start_date)
56
56
  end
57
57
  end
58
58
  end
@@ -2,8 +2,10 @@ require "active_record"
2
2
 
3
3
  module HubStore
4
4
  class PullRequest < ActiveRecord::Base
5
- def self.resume_date
6
- group(:repo).order(updated_at: :asc).pluck(:updated_at).min
5
+ scope :recently_updated_first, -> { order(updated_at: :desc) }
6
+
7
+ def self.for(repo)
8
+ where(repo: repo)
7
9
  end
8
10
  end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module HubStore
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '0.4'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: '0.4'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: sqlite3
141
141
  requirement: !ruby/object:Gem::Requirement