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
|
token string
|
||||||
num int
|
num int
|
||||||
projectId int
|
projectId int
|
||||||
|
filterId int
|
||||||
minimumVersion string
|
minimumVersion string
|
||||||
tmpl *template.Template
|
tmpl *template.Template
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
@ -60,15 +61,7 @@ func NewData(ctx context.Context, url, token string, num int) *Data {
|
|||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
num: num,
|
num: num,
|
||||||
}
|
}
|
||||||
fm := map[string]any{
|
data.tmpl = template.Must(template.New("index").ParseFS(content, "*.tmpl"))
|
||||||
"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"))
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@ -126,11 +119,10 @@ func (d *Data) getProject() {
|
|||||||
d.Timestamp = time.Now()
|
d.Timestamp = time.Now()
|
||||||
d.Project = project
|
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",
|
var fields = []string{"id",
|
||||||
"description",
|
"description",
|
||||||
"summary",
|
"summary",
|
||||||
@ -149,9 +141,12 @@ var fields = []string{"id",
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Data) getIssues() {
|
func (d *Data) getIssues() {
|
||||||
url := fmt.Sprintf("%s/issues?project_id=%d&page_size=%d&%s&select=%s",
|
url := fmt.Sprintf("%s/issues?project_id=%d&filter_id=%d&select=%s&page_size=%d",
|
||||||
d.url, d.projectId, d.num, statusFilter,
|
d.url,
|
||||||
strings.Join(fields, ","))
|
d.projectId,
|
||||||
|
d.filterId,
|
||||||
|
strings.Join(fields, ","),
|
||||||
|
d.num)
|
||||||
req, e := http.NewRequestWithContext(d.ctx, "GET", url, nil)
|
req, e := http.NewRequestWithContext(d.ctx, "GET", url, nil)
|
||||||
if nil != e {
|
if nil != e {
|
||||||
d.mux.Lock()
|
d.mux.Lock()
|
||||||
@ -202,7 +197,11 @@ func (d *Data) getIssues() {
|
|||||||
}
|
}
|
||||||
d.Issues = issues
|
d.Issues = issues
|
||||||
d.Features = features
|
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() {
|
func (d *Data) Loop() {
|
||||||
|
2
main.go
2
main.go
@ -38,6 +38,7 @@ var (
|
|||||||
fl_min = flag.String("min", "0.9.1", "minimum version we care for")
|
fl_min = flag.String("min", "0.9.1", "minimum version we care for")
|
||||||
fl_freq = flag.Duration("fr", 30*time.Minute, "update frequency")
|
fl_freq = flag.Duration("fr", 30*time.Minute, "update frequency")
|
||||||
fl_proj = flag.Int("project", 23, "project id to use")
|
fl_proj = flag.Int("project", 23, "project id to use")
|
||||||
|
fl_filter = flag.Int("filter", 229, "filter id to apply for search")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -47,6 +48,7 @@ func main() {
|
|||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
var data = NewData(ctx, *fl_url, *fl_token, *fl_num)
|
var data = NewData(ctx, *fl_url, *fl_token, *fl_num)
|
||||||
data.projectId = *fl_proj
|
data.projectId = *fl_proj
|
||||||
|
data.filterId = *fl_filter
|
||||||
data.minimumVersion = *fl_min
|
data.minimumVersion = *fl_min
|
||||||
data.Freq = *fl_freq
|
data.Freq = *fl_freq
|
||||||
|
|
||||||
|
11
table.tmpl
11
table.tmpl
@ -63,20 +63,22 @@ details.version {
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="side"></th>
|
<th class="side"></th>
|
||||||
{{- range $top.TargetVersions }}
|
{{- range $vname := $top.TargetVersions }}
|
||||||
|
{{- with $version := $versions.Get . }}
|
||||||
<th>
|
<th>
|
||||||
<details class="version">
|
<details class="version">
|
||||||
{{- $version := $versions.Get . }}
|
<summary><b>{{ $vname }}</b> ({{ $version.Timestamp.Format "02 Jan 06"}})</summary>
|
||||||
<summary><b>{{ . }}</b> ({{ $version.Timestamp.Format "02 Jan 06"}})</summary>
|
<div>{{ $version.Description }}</div>
|
||||||
<div>{{$version.Description }}</div>
|
|
||||||
</details>
|
</details>
|
||||||
</th>
|
</th>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{- end}}
|
||||||
</tr>
|
</tr>
|
||||||
{{- range $cat := $top.Categories }}
|
{{- range $cat := $top.Categories }}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="side">{{ . }}</th>
|
<th class="side">{{ . }}</th>
|
||||||
{{- range $tar := $top.TargetVersions }}
|
{{- range $tar := $top.TargetVersions }}
|
||||||
|
{{- with $version := $versions.Get . }}
|
||||||
<td>{{ with $features.ByCategoryAndTarget $cat $tar }}
|
<td>{{ with $features.ByCategoryAndTarget $cat $tar }}
|
||||||
<details class="feature">
|
<details class="feature">
|
||||||
<summary>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} features{{ else }}1 feature{{ end }}</summary>
|
<summary>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} features{{ else }}1 feature{{ end }}</summary>
|
||||||
@ -93,6 +95,7 @@ details.version {
|
|||||||
</details>
|
</details>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
</td>{{ end }}
|
</td>{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tr>
|
</tr>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user