ensure canonical order: latest first;
authorwenzelm
Mon, 01 May 2017 11:04:33 +0200
changeset 65659 293141fb093d
parent 65658 be817b7b8354
child 65660 dfecaf0fc069
ensure canonical order: latest first;
src/Pure/Admin/build_stats.scala
src/Pure/Admin/jenkins.scala
--- a/src/Pure/Admin/build_stats.scala	Mon May 01 11:00:27 2017 +0200
+++ b/src/Pure/Admin/build_stats.scala	Mon May 01 11:04:33 2017 +0200
@@ -24,7 +24,7 @@
     elapsed_threshold: Time = default_elapsed_threshold,
     ml_timing: Option[Boolean] = default_ml_timing): List[String] =
   {
-    val job_infos = Jenkins.build_job_infos(job).sortBy(_.timestamp).reverse.take(history_length)
+    val job_infos = Jenkins.build_job_infos(job).take(history_length)
     if (job_infos.isEmpty) error("No build infos for job " + quote(job))
 
     val all_infos =
--- a/src/Pure/Admin/jenkins.scala	Mon May 01 11:00:27 2017 +0200
+++ b/src/Pure/Admin/jenkins.scala	Mon May 01 11:04:33 2017 +0200
@@ -112,23 +112,26 @@
   {
     val Session_Log = new Regex("""^.*/log/([^/]+)\.(db|gz)$""")
 
-    for {
-      build <-
-        JSON.array(
-          invoke(root() + "/job/" + job_name, "tree=allBuilds[number,timestamp,artifacts[*]]"),
-          "allBuilds").getOrElse(Nil)
-      number <- JSON.int(build, "number")
-      timestamp <- JSON.long(build, "timestamp")
-    } yield {
-      val job_prefix = root() + "/job/" + job_name + "/" + number
-      val main_log = Url(job_prefix + "/consoleText")
-      val session_logs =
-        for {
-          artifact <- JSON.array(build, "artifacts").getOrElse(Nil)
-          log_path <- JSON.string(artifact, "relativePath")
-          (name, ext) <- (log_path match { case Session_Log(a, b) => Some((a, b)) case _ => None })
-        } yield (name, ext, Url(job_prefix + "/artifact/" + log_path))
-      Job_Info(job_name, timestamp, main_log, session_logs)
-    }
+    val infos =
+      for {
+        build <-
+          JSON.array(
+            invoke(root() + "/job/" + job_name, "tree=allBuilds[number,timestamp,artifacts[*]]"),
+            "allBuilds").getOrElse(Nil)
+        number <- JSON.int(build, "number")
+        timestamp <- JSON.long(build, "timestamp")
+      } yield {
+        val job_prefix = root() + "/job/" + job_name + "/" + number
+        val main_log = Url(job_prefix + "/consoleText")
+        val session_logs =
+          for {
+            artifact <- JSON.array(build, "artifacts").getOrElse(Nil)
+            log_path <- JSON.string(artifact, "relativePath")
+            (name, ext) <- (log_path match { case Session_Log(a, b) => Some((a, b)) case _ => None })
+          } yield (name, ext, Url(job_prefix + "/artifact/" + log_path))
+        Job_Info(job_name, timestamp, main_log, session_logs)
+      }
+
+    infos.sortBy(info => - info.timestamp)
   }
 }