Browse Source

Sort the ps output

Provide consistent ordering for the ps command - longest duration listed first
Daniel Hiltgen 10 months ago
parent
commit
642cee1342
1 changed files with 5 additions and 0 deletions
  1. 5 0
      server/routes.go

+ 5 - 0
server/routes.go

@@ -1224,6 +1224,11 @@ func (s *Server) ProcessHandler(c *gin.Context) {
 		models = append(models, mr)
 	}
 
+	slices.SortStableFunc(models, func(i, j api.ProcessModelResponse) int {
+		// longest duration remaining listed first
+		return cmp.Compare(j.ExpiresAt.Unix(), i.ExpiresAt.Unix())
+	})
+
 	c.JSON(http.StatusOK, api.ProcessResponse{Models: models})
 }