https://github.com/jeremyf/github_reporter
Query and report on a set of Github repositories over a period of time.
https://github.com/jeremyf/github_reporter
ruby
Last synced: 5 days ago
JSON representation
Query and report on a set of Github repositories over a period of time.
- Host: GitHub
- URL: https://github.com/jeremyf/github_reporter
- Owner: jeremyf
- Created: 2022-01-31T20:44:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-29T22:54:08.000Z (over 4 years ago)
- Last Synced: 2025-03-24T05:45:52.914Z (over 1 year ago)
- Topics: ruby
- Language: Ruby
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GithubReporter
This gem is responsible for querying and reporting on a set of repositories over a period of time. It's been quickly fleshed out as a proof of concept.
The idea is to connect issues and pull requests, but also to identify pull requests that might not have tracked to issues.
## Installation
TBD.
## Usage
At present there's not a tidy interface, but below is an example I used to build out the initial implementation.
Before you even get started you'll need a Github OAuth key. Once you have that:
```sh
export GITHUB_OAUTH_TOKEN=""
```
First we want to establishing the reporting scope:
```ruby
scope = GithubReporter::Scope.new(
repository_names: ["forem/rfcs", "forem/forem"],
report_since_date: Time.parse("2022-01-01T00:00:00Z"),
report_until_date: Time.parse("2022-02-01T00:00:00Z")
)
```
Then we fetch the remote information:
```ruby
fetcher = GithubReporter::Fetcher.new(scope: scope)
data_store = fetcher.call
```
Since fetching the remote information can be expensive, I cached the fetched results locally:
```ruby
File.open("data_store_dump.txt", "w+") do |f|
f.puts Marshal.dump(data_store)
end
```
I could then load the local cached values to run the report:
```ruby
data_store = Marshal.load(File.read("data_store_dump.txt"))
GithubReporter::Reporter.render(data_store: data_store, scope: scope, format: :csv)
```
Alternatively, if you don't want to use caching, you can use the `GithubReporter.run` method:
```ruby
GithubReporter.run(
since_date: "2022-01-01",
until_date: "2022-02-01",
repos: ["forem/forem", "forem/rfcs"],
format: :csv,
auth_token: ENV.fetch["GITHUB_OAUTH_TOKEN"],
buffer: $stdout
)
```
The above will live query Github and render output to given buffer.
Or if you'd prefer to write to a file:
```ruby
File.open("report-2022-03.csv", "w+") do |fbuffer|
GithubReporter.run(
format: :csv,
since_date: "2022-03-01",
until_date: "2022-04-01",
repos: ["forem/forem", "forem/rfcs"],
auth_token: ENV.fetch("GITHUB_OAUTH_TOKEN"),
# This doesn't yet work
data_store: "data_store.dump",
buffer: fbuffer,
labels_to_report: ["changelog: rollup", "changelog: spotlight", "changelog: advance", "changelog: none"]
)
end
```
And because I've run this a few times, I added a script (which I need to update the dates).
```shell
$ GITHUB_OAUTH_TOKEN= bundle exec ruby ./to_run.rb
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jeremyf/github_reporter.