-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://github.com/elifesciences/maintainers-txt
- Loading branch information
Showing
7 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ maintainers-txt | |
linux-amd64 | ||
linux-amd64.sha256 | ||
alias-map.json | ||
output.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,13 @@ and `alias-map.json` might look like: | |
{"jdoe": "[email protected]"} | ||
``` | ||
|
||
### Graph | ||
|
||
To generate a simple pie chart from the output of the `maintainers-txt`: | ||
|
||
GITHUB_TOKEN=your-github-token ./maintainers-txt > report.json | ||
go run . graph | ||
|
||
## Licence | ||
|
||
Copyright © 2024 eLife Sciences | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/wcharczuk/go-chart/v2" | ||
) | ||
|
||
func graph() { | ||
report_file := "report.json" | ||
report_bytes, err := os.ReadFile(report_file) | ||
panicOnErr(err, "reading report.json") | ||
|
||
dest := map[string][]string{} | ||
json.Unmarshal(report_bytes, &dest) | ||
|
||
// each slice of the chart is a person, | ||
// the value of each slice is the sum of each percentage | ||
// of each repository they are responsible for. | ||
|
||
person_value_idx := map[string]float64{} | ||
for _, person_list := range dest { | ||
num_people := float64(len(person_list)) | ||
for _, person := range person_list { | ||
person_value, present := person_value_idx[person] | ||
if !present { | ||
person_value = 0 | ||
} | ||
person_value += 1.0 / num_people | ||
person_value_idx[person] = person_value | ||
} | ||
} | ||
|
||
vals := []chart.Value{} | ||
for person, value := range person_value_idx { | ||
vals = append(vals, chart.Value{Value: value, Label: person}) | ||
} | ||
|
||
pie := chart.PieChart{ | ||
Width: 512, | ||
Height: 512, | ||
Values: vals, | ||
} | ||
|
||
f, _ := os.Create("output.svg") | ||
defer f.Close() | ||
pie.Render(chart.SVG, f) | ||
fmt.Println("wrote output.svg") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters