introduce filterid; cleanup
This commit is contained in:
parent
cb0d3edd44
commit
354370a523
31
data.go
31
data.go
@ -41,6 +41,7 @@ type Data struct {
|
||||
token string
|
||||
num int
|
||||
projectId int
|
||||
filterId int
|
||||
minimumVersion string
|
||||
tmpl *template.Template
|
||||
ctx context.Context
|
||||
@ -60,15 +61,7 @@ func NewData(ctx context.Context, url, token string, num int) *Data {
|
||||
ctx: ctx,
|
||||
num: num,
|
||||
}
|
||||
fm := map[string]any{
|
||||
"shorten": func(max int, s string) string {
|
||||
if len(s) <= max {
|
||||
return s
|
||||
}
|
||||
return s[:max] + "⋯"
|
||||
},
|
||||
}
|
||||
data.tmpl = template.Must(template.New("index").Funcs(fm).ParseFS(content, "*.tmpl"))
|
||||
data.tmpl = template.Must(template.New("index").ParseFS(content, "*.tmpl"))
|
||||
|
||||
return data
|
||||
}
|
||||
@ -126,11 +119,10 @@ func (d *Data) getProject() {
|
||||
d.Timestamp = time.Now()
|
||||
d.Project = project
|
||||
|
||||
log.Println("Got project details for id", d.projectId, "with", len(d.Project.Versions), "version entries")
|
||||
log.Println("Got project details for id", d.projectId,
|
||||
"with", len(d.Project.Versions), "version entries")
|
||||
}
|
||||
|
||||
const statusFilter = `status%5B%5D=10&status%5B%5D=20&status%5B%5D=30&status%5B%5D=40&status%5B%5D=50&severity%5B%5D=20`
|
||||
|
||||
var fields = []string{"id",
|
||||
"description",
|
||||
"summary",
|
||||
@ -149,9 +141,12 @@ var fields = []string{"id",
|
||||
}
|
||||
|
||||
func (d *Data) getIssues() {
|
||||
url := fmt.Sprintf("%s/issues?project_id=%d&page_size=%d&%s&select=%s",
|
||||
d.url, d.projectId, d.num, statusFilter,
|
||||
strings.Join(fields, ","))
|
||||
url := fmt.Sprintf("%s/issues?project_id=%d&filter_id=%d&select=%s&page_size=%d",
|
||||
d.url,
|
||||
d.projectId,
|
||||
d.filterId,
|
||||
strings.Join(fields, ","),
|
||||
d.num)
|
||||
req, e := http.NewRequestWithContext(d.ctx, "GET", url, nil)
|
||||
if nil != e {
|
||||
d.mux.Lock()
|
||||
@ -202,7 +197,11 @@ func (d *Data) getIssues() {
|
||||
}
|
||||
d.Issues = issues
|
||||
d.Features = features
|
||||
log.Println("Got", len(iss.Issues), "entries, of which", open, "are open and relevant:", len(features), "features and", len(issues), "issues")
|
||||
log.Println("Got",
|
||||
len(iss.Issues), "entries, of which",
|
||||
open, "are open and relevant:",
|
||||
len(features), "features and",
|
||||
len(issues), "issues")
|
||||
}
|
||||
|
||||
func (d *Data) Loop() {
|
||||
|
16
main.go
16
main.go
@ -31,13 +31,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fl_url = flag.String("url", "https://bugs.gnunet.org/api/rest", "URL to the issues")
|
||||
fl_token = flag.String("token", os.Getenv("MANTIS_API_TOKEN"), "API-Token")
|
||||
fl_port = flag.String("port", ":8080", "[ip]:port to serve")
|
||||
fl_num = flag.Int("num", 250, "number of issues to retrieve at once")
|
||||
fl_min = flag.String("min", "0.9.1", "minimum version we care for")
|
||||
fl_freq = flag.Duration("fr", 30*time.Minute, "update frequency")
|
||||
fl_proj = flag.Int("project", 23, "project id to use")
|
||||
fl_url = flag.String("url", "https://bugs.gnunet.org/api/rest", "URL to the issues")
|
||||
fl_token = flag.String("token", os.Getenv("MANTIS_API_TOKEN"), "API-Token")
|
||||
fl_port = flag.String("port", ":8080", "[ip]:port to serve")
|
||||
fl_num = flag.Int("num", 250, "number of issues to retrieve at once")
|
||||
fl_min = flag.String("min", "0.9.1", "minimum version we care for")
|
||||
fl_freq = flag.Duration("fr", 30*time.Minute, "update frequency")
|
||||
fl_proj = flag.Int("project", 23, "project id to use")
|
||||
fl_filter = flag.Int("filter", 229, "filter id to apply for search")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -47,6 +48,7 @@ func main() {
|
||||
var ctx = context.Background()
|
||||
var data = NewData(ctx, *fl_url, *fl_token, *fl_num)
|
||||
data.projectId = *fl_proj
|
||||
data.filterId = *fl_filter
|
||||
data.minimumVersion = *fl_min
|
||||
data.Freq = *fl_freq
|
||||
|
||||
|
11
table.tmpl
11
table.tmpl
@ -63,20 +63,22 @@ details.version {
|
||||
<table>
|
||||
<tr>
|
||||
<th class="side"></th>
|
||||
{{- range $top.TargetVersions }}
|
||||
{{- range $vname := $top.TargetVersions }}
|
||||
{{- with $version := $versions.Get . }}
|
||||
<th>
|
||||
<details class="version">
|
||||
{{- $version := $versions.Get . }}
|
||||
<summary><b>{{ . }}</b> ({{ $version.Timestamp.Format "02 Jan 06"}})</summary>
|
||||
<div>{{$version.Description }}</div>
|
||||
<summary><b>{{ $vname }}</b> ({{ $version.Timestamp.Format "02 Jan 06"}})</summary>
|
||||
<div>{{ $version.Description }}</div>
|
||||
</details>
|
||||
</th>
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
</tr>
|
||||
{{- range $cat := $top.Categories }}
|
||||
<tr>
|
||||
<th class="side">{{ . }}</th>
|
||||
{{- range $tar := $top.TargetVersions }}
|
||||
{{- with $version := $versions.Get . }}
|
||||
<td>{{ with $features.ByCategoryAndTarget $cat $tar }}
|
||||
<details class="feature">
|
||||
<summary>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} features{{ else }}1 feature{{ end }}</summary>
|
||||
@ -93,6 +95,7 @@ details.version {
|
||||
</details>
|
||||
{{ end -}}
|
||||
</td>{{ end }}
|
||||
{{ end }}
|
||||
</tr>
|
||||
{{- end}}
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user