11package system
22
33import (
4- "cmp"
54 "encoding/json"
65 "github.com/gofiber/fiber/v2"
76 "github.com/typomedia/patchouli/app/store/boltdb"
87 "github.com/typomedia/patchouli/app/structs"
9- "slices"
108)
119
1210func List (c * fiber.Ctx ) error {
@@ -20,6 +18,7 @@ func List(c *fiber.Ctx) error {
2018 systems , _ := db .GetAll ("systems" )
2119
2220 Systems := structs.Systems {}
21+ systemsWithoutEOL := structs.Systems {}
2322 for _ , v := range systems {
2423 system := structs.System {}
2524 err = json .Unmarshal (v , & system )
@@ -31,11 +30,16 @@ func List(c *fiber.Ctx) error {
3130 return err
3231 }
3332 system .MachineCount = len (machinesOfSystem )
34- Systems = append (Systems , system )
33+ if system .EOL == "" {
34+ systemsWithoutEOL = append (systemsWithoutEOL , system )
35+ } else {
36+ Systems = append (Systems , system )
37+ }
3538 }
36- slices .SortFunc (Systems , func (a , b structs.System ) int {
37- return cmp .Compare (b .MachineCount , a .MachineCount )
38- })
39+
40+ Systems .OrderedBy (Systems .ByName (), Systems .ByEOL ()).Sort (Systems )
41+ Systems = append (Systems , systemsWithoutEOL ... )
42+
3943 defer db .Close ()
4044
4145 return c .Render ("app/views/system/list" , fiber.Map {
0 commit comments