diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2016-11-02 12:31:24 +0000 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2016-11-02 12:31:24 +0000 |
commit | 39f42a74d9ab71ff1791135a78105a36ede0aeed (patch) | |
tree | d6a0b710629f3adff90bfdffd2989cf097d84993 | |
parent | 6db7c7e7715007fb7e7ce683763877474f39d5c4 (diff) |
lava-list-jobs-mode: clean up table print
-rw-r--r-- | lava-job-list-mode.el | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/lava-job-list-mode.el b/lava-job-list-mode.el index e5b92ab..f5db789 100644 --- a/lava-job-list-mode.el +++ b/lava-job-list-mode.el @@ -73,7 +73,7 @@ Letters do not insert themselves; instead, they are commands. ("Bundle" 15 nil) ("Results URL" 20 nil)]) (setq tabulated-list-use-header-line 't) - (setq tabulated-list-sort-key (cons "Job ID" nil)) + (setq tabulated-list-sort-key nil) (message "setup mode") (add-hook 'tabulated-list-revert-hook 'lava-job-list--refresh nil t) (message "initialising header") @@ -152,39 +152,38 @@ Letters do not insert themselves; instead, they are commands. (unless (gethash "actual_device_id" info-hash) (lava-job-list-get-details jobid)))))) +(defun lava-job-list--format-row (job) + "Format a row of `JOB' for `tabulated-list-entries'." + (let ((info-hash (lava-jobs-get-hash job))) + (vector (format "%s" (gethash "job_id" info-hash)) + (or (gethash "description" info-hash) + "unknown") + ;; updated + (format-time-string + lava-job-list-mode-time-format + (gethash "updated" info-hash)) + ;; status + (or + (gethash "job_status" info-hash) + "Unknown") + ;; + (or + (gethash "bundle_sha1" info-hash) + "Unknown") + ;; link to results + (format + "http://%s/scheduler/job/%s" + lava-host (gethash "job_id" info-hash))))) + (defun lava-job-list--refresh () "Refresh the list of `JOBS' in the display." (with-current-buffer (lava-job-list--buffer) - (let (entries) + (let (entries '()) (-each (-map 'car lava-job-info) (lambda (job) (lava-start-polling-job job) - (let* ((info-hash (lava-jobs-get-hash job)) - (status - (or - (gethash "job_status" info-hash) - "Unknown")) - (description - (or (gethash "description" info-hash) - "unknown")) - (jobid (gethash "job_id" info-hash)) - (updated - (format-time-string - lava-job-list-mode-time-format - (gethash "updated" info-hash))) - (bundle - (or - (gethash "bundle_sha1" info-hash) - "Unknown")) - (url - (format - "http://%s/scheduler/job/%s" - lava-host jobid))) - (when (string-match "omplete" status) - (lava-stop-polling-job job)) - (let ((line (vector jobid description updated status bundle url))) - (push `(,job ,line) entries))))) - (setq tabulated-list-entries (nreverse entries))) + (add-to-list 'entries `(,job ,(lava-job-list--format-row job))))) + (setq tabulated-list-entries entries)) (tabulated-list-init-header) (tabulated-list-print))) |