소스 검색

Sort the ps output

Provide consistent ordering for the ps command - longest duration listed first
Daniel Hiltgen 10 달 전
부모
커밋
03bb60e036
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      server/routes.go

+ 5 - 0
server/routes.go

@@ -1237,6 +1237,11 @@ func (s *Server) ProcessHandler(c *gin.Context) {
 		models = append(models, mr)
 		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})
 	c.JSON(http.StatusOK, api.ProcessResponse{Models: models})
 }
 }