71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"time"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
type Repo struct {
|
|
owner string
|
|
repo string
|
|
}
|
|
|
|
func main() {
|
|
client, err := gitea.NewClient(
|
|
"https://git.schreifuchs.ch",
|
|
gitea.SetToken("6a8ea8f9de039b0950c634bfea40c6f97f94b06b"),
|
|
)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
var issues []*gitea.Issue
|
|
for _, repo := range []Repo{
|
|
{"lou-taylor", "lou-taylor-web"},
|
|
{"lou-taylor", "lou-taylor-api"},
|
|
{"lou-taylor", "accounting"},
|
|
} {
|
|
iss, _, err := client.ListRepoIssues(
|
|
repo.owner,
|
|
repo.repo,
|
|
gitea.ListIssueOption{
|
|
ListOptions: gitea.ListOptions{Page: 0, PageSize: 99999},
|
|
Since: time.Now().AddDate(0, -1, 0),
|
|
Before: time.Now(),
|
|
},
|
|
)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
issues = append(issues, iss...)
|
|
}
|
|
// for _, issue := range issues {
|
|
// fmt.Println(issue.Body)
|
|
// }
|
|
//
|
|
issues = Filter(
|
|
issues,
|
|
func(i *gitea.Issue) bool {
|
|
return i.Closed != nil && i.Closed.After(time.Now().AddDate(0, -1, 0))
|
|
},
|
|
)
|
|
|
|
json.NewEncoder(os.Stdout).Encode(issues)
|
|
}
|
|
|
|
func Filter[T any](slice []T, ok func(T) bool) []T {
|
|
out := make([]T, 0, len(slice))
|
|
|
|
for _, item := range slice {
|
|
if ok(item) {
|
|
out = append(out, item)
|
|
}
|
|
}
|
|
|
|
return out
|
|
}
|