浏览代码

Sort the ps output

Provide consistent ordering for the ps command - longest duration listed first
Daniel Hiltgen 10 月之前
父节点
当前提交
642cee1342
共有 1 个文件被更改,包括 5 次插入0 次删除
  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})
 }