sort target versions by release date

This commit is contained in:
Özgür Kesim 2024-09-04 20:08:49 +02:00
parent b9b128e92f
commit 7eb6abf250
Signed by: oec
GPG Key ID: F136A7F922D018D7
2 changed files with 13 additions and 10 deletions

View File

@ -63,6 +63,7 @@ func NewData(ctx context.Context, url, token string, num int) *Data {
} }
funcMap := map[string]any{ funcMap := map[string]any{
"OrderedBy": OrderedBy, "OrderedBy": OrderedBy,
"Reverse": sort.Reverse,
} }
data.tmpl = template.Must(template.New("index").Funcs(funcMap).ParseFS(content, "*.tmpl")) data.tmpl = template.Must(template.New("index").Funcs(funcMap).ParseFS(content, "*.tmpl"))
@ -284,6 +285,11 @@ func (d *Data) VersionsByDate() VersionsByDate {
return VersionsByDate(d.Project.Versions) return VersionsByDate(d.Project.Versions)
} }
func (d VersionsByDate) Sort() VersionsByDate {
sort.Sort(d)
return d
}
func (d *Data) Categories() (cs []string) { func (d *Data) Categories() (cs []string) {
d.mux.RLock() d.mux.RLock()
defer d.mux.RUnlock() defer d.mux.RUnlock()

View File

@ -91,30 +91,27 @@ details[open].issue {
{{- $top := . -}} {{- $top := . -}}
{{- $features := .Features -}} {{- $features := .Features -}}
{{- $issues := .Issues -}} {{- $issues := .Issues -}}
{{- $versions := .VersionsByDate -}} {{- $versions := .VersionsByDate.Sort -}}
<!--p> <!--p>
{{- range $top.Tags -}}<button>{{ . }}</button>{{- end -}} {{- range $top.Tags -}}<button>{{ . }}</button>{{- end -}}
</p--> </p-->
<table> <table>
<tr> <tr>
<th class="side"></th> <th class="side"></th>
{{- range $vname := $top.TargetVersions }} {{- range $version := $versions }}
{{- with $version := $versions.Get . }}
<th> <th>
<details class="version"> <details class="version">
<summary><b>{{ $vname }}</b> <span class="right">({{ $version.Timestamp.Format "02 Jan 06"}})</span></summary> <summary><b>{{ $version.Name }}</b> <span class="right">({{ $version.Timestamp.Format "02 Jan 06"}})</span></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 $version := $versions }}
{{- with $version := $versions.Get . }} <td><div class="minh">{{ with $features.ByCategoryAndTarget $cat $version.Name }}
<td><div class="minh">{{ with $features.ByCategoryAndTarget $cat $tar }}
<details class="feature"> <details class="feature">
<summary> <summary>
<div>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} features{{ else }}1 feature{{ end }}</div> <div>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} features{{ else }}1 feature{{ end }}</div>
@ -133,7 +130,7 @@ details[open].issue {
{{- end}} {{- end}}
</details> </details>
{{- end }} {{- end }}
{{- with $issues.ByCategoryAndTarget $cat $tar }} {{- with $issues.ByCategoryAndTarget $cat $version.Name }}
<details class="issue"> <details class="issue">
<summary> <summary>
<div>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} issues{{ else }}1 issue{{ end }}</div> <div>{{ $l := len .}}{{ if lt 1 $l }}{{ $l }} issues{{ else }}1 issue{{ end }}</div>
@ -147,7 +144,7 @@ details[open].issue {
{{- end}} {{- end}}
</details> </details>
{{ end -}} {{ end -}}
</div></td>{{ end }} </div></td>
{{ end }} {{ end }}
</tr> </tr>
{{- end}} {{- end}}