hub_store 0.4.0 → 0.5.0
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 +4 -4
- data/README.md +5 -26
- data/hub_store.gemspec +1 -1
- data/lib/hub_store/cli.rb +8 -5
- data/lib/hub_store/importer.rb +4 -4
- data/lib/hub_store/pull_request.rb +4 -2
- data/lib/hub_store/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a563df0ec7313beaea07c489b97458c9598f43d4a2ec408a421fa1e8af98ec9
|
4
|
+
data.tar.gz: 853e8cbf787e7a406965a4b3c8566d17e17dfb67d2b2104bb1fdfeb6a691c7f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
10
|
-
|
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
|
-
|
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/
|
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
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
|
-
|
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
|
data/lib/hub_store/importer.rb
CHANGED
@@ -6,8 +6,8 @@ require "hub_store/review_request"
|
|
6
6
|
|
7
7
|
module HubStore
|
8
8
|
class Importer
|
9
|
-
def initialize(
|
10
|
-
@
|
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 :
|
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(
|
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
|
-
|
6
|
-
|
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
|
data/lib/hub_store/version.rb
CHANGED
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
|
+
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
|