Merge pull request #47 from cfinegan/master

Alerts for Outstanding Package Maintenance
This commit is contained in:
Jay McCarthy 2017-07-12 09:44:44 -06:00 committed by GitHub
commit 9cafa90c69
2 changed files with 107 additions and 30 deletions

View File

@ -593,46 +593,72 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (package-summary-table package-names) (define (package-summary-table package-names)
(define now (/ (current-inexact-milliseconds) 1000)) (define-values (pkg-rows num-todos)
(build-pkg-rows/num-todos package-names))
`(table `(table
((class "packages sortable")) ((class "packages sortable") (data-todokey ,num-todos))
(thead (thead
(tr (tr
(th 'nbsp) (th 'nbsp)
(th "Package") (th "Package")
(th "Description") (th "Description")
(th "Build"))) (th "Build")
(th ((style "display: none")) 'nbsp))) ;; todokey
(tbody (tbody
,@(maybe-splice (null? package-names) ,@(maybe-splice (null? package-names)
`(tr (td ((colspan "4")) `(tr (td ((colspan "4"))
(div ((class "alert alert-info")) (div ((class "alert alert-info"))
"No packages found.")))) "No packages found."))))
,@(for/list ((pkg (package-batch-detail package-names))) ,@pkg-rows)))
`(tr
(td (span ((class "last-updated-negated") (style "display: none")) (define (build-pkg-rows/num-todos package-names)
,(~a (- (package-last-updated pkg)))) ;; Builds the list of rows in the package table as an x-exp.
,@(maybe-splice ;; Also returns the total number of non-zero todo keys,
(< (- now (package-last-updated pkg)) recent-seconds) ;; representing packages with outstanding build errors or
`(span ((class "label label-info")) "New"))) ;; failing tests, or which are missing docs or tags.
(td (h2 ,(package-link (package-name pkg))) (define now (/ (current-inexact-milliseconds) 1000))
,(authors-list (package-authors pkg))) (define-values (pkg-rows num-todos)
(td (p ,(package-description pkg)) (for/fold ([pkg-rows null] [num-todos 0])
,@(maybe-splice ([pkg (package-batch-detail package-names)])
(or (pair? (package-docs pkg)) (package-readme-url pkg)) (define has-docs? (pair? (package-docs pkg)))
`(div (define has-readme? (pair? (package-readme-url pkg)))
(span ((class "doctags-label")) "Docs: ") (define has-tags? (pair? (package-tags pkg)))
,(doc-links (package-docs pkg)) (define todokey
,@(maybe-splice (package-readme-url pkg) (cond [(package-build-failure-log pkg) 4]
" " [(package-build-test-failure-log pkg) 3]
`(a ((href ,(package-readme-url pkg))) [(not (or has-docs? has-readme?)) 2]
"README")) [(not has-tags?) 1]
)) [else 0]))
,@(maybe-splice (define row-xexp
(pair? (package-tags pkg)) `(tr
`(div ((data-todokey ,todokey))
(span ((class "doctags-label")) "Tags: ") (td (span ((class "last-updated-negated") (style "display: none"))
,(tag-links (package-tags pkg))))) ,(~a (- (package-last-updated pkg))))
,(build-status-td pkg)))))) ,@(maybe-splice
(< (- now (package-last-updated pkg)) recent-seconds)
`(span ((class "label label-info")) "New")))
(td (h2 ,(package-link (package-name pkg)))
,(authors-list (package-authors pkg)))
(td (p ,(package-description pkg))
,@(maybe-splice
(or has-docs? has-readme?)
`(div
(span ((class "doctags-label")) "Docs: ")
,(doc-links (package-docs pkg))
,@(maybe-splice has-readme?
" "
`(a ((href ,(package-readme-url pkg)))
"README"))))
,@(maybe-splice
has-tags?
`(div
(span ((class "doctags-label")) "Tags: ")
,(tag-links (package-tags pkg)))))
,(build-status-td pkg)
(td ((style "display: none")) ,todokey)))
(values (cons row-xexp pkg-rows) (if (> 0 todokey) (add1 num-todos) num-todos))))
;; for/fold reverses pkg-rows, so un-reverse before returning.
(values (reverse pkg-rows) num-todos))
(define (build-status-td pkg) (define (build-status-td pkg)
;; Build the index page cell for summarizing a package's build status. ;; Build the index page cell for summarizing a package's build status.
@ -660,12 +686,14 @@
(match-define (list u p l) e) (match-define (list u p l) e)
(if u `(span ,p ,(buildhost-link u l)) `(span))))) (if u `(span ,p ,(buildhost-link u l)) `(span)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (main-page request) (define (main-page request)
(parameterize ((bootstrap-active-navigation nav-index) (parameterize ((bootstrap-active-navigation nav-index)
(bootstrap-page-scripts (list (static-resource-url "/searchbox.js") (bootstrap-page-scripts (list (static-resource-url "/searchbox.js")
(static-resource-url "/index.js")))) (static-resource-url "/index.js")
(static-resource-url "/todos.js"))))
(define package-name-list (package-search "" '((main-distribution #f) (define package-name-list (package-search "" '((main-distribution #f)
(main-tests #f) (main-tests #f)
(deprecated #f)))) (deprecated #f))))
@ -700,6 +728,7 @@
,(format "~a packages" (length package-name-list)) ,(format "~a packages" (length package-name-list))
" " " "
(a ((href ,(format "~a?q=%20" (named-url search-page)))) "(see all, including packages tagged as \"deprecated\", \"main-distribution\", or \"main-test\")")) (a ((href ,(format "~a?q=%20" (named-url search-page)))) "(see all, including packages tagged as \"deprecated\", \"main-distribution\", or \"main-test\")"))
(p ((class "package-count") (id "todo-msg")) "") ;; filled in by client-side JS.
,(package-summary-table package-name-list)) ,(package-summary-table package-name-list))
`(div ((class "jumbotron")) `(div ((class "jumbotron"))
(p "Questions? Comments? Bugs? Email " (p "Questions? Comments? Bugs? Email "

48
static/todos.js Normal file
View File

@ -0,0 +1,48 @@
$(function() {
"use strict";
function applyFilter() {
$("table.packages > tbody > tr").each(function() {
var row = this;
if (Number.parseInt($(row).data("todokey"), 10) === 0) {
row.style.display = "none";
}
});
$("table.packages").trigger("sorton", [[[4, 1]]]);
}
function removeFilter() {
$("table.packages > tbody > tr").each(function() {
var row = this;
if (Number.parseInt($(row).data("todokey"), 10) === 0) {
row.style.display = "";
}
});
$("table.packages").trigger("sorton", [[[1, 0]]]);
}
var todoTotal = $("table.packages").data("todokey");
if (todoTotal > 0) {
$("#todo-msg").html(
todoTotal + " todos. " +
"<a style='cursor:pointer' id='filter-pkgs'> Click here to see them.</a>"
);
var filterIsApplied = false;
$("#filter-pkgs").click(function() {
var filterLink = $(this);
if (!filterIsApplied) {
applyFilter();
filterLink.text("Click to see all packages.");
filterIsApplied = true;
} else {
removeFilter();
filterLink.text("Click here to see them.");
filterIsApplied = false;
}
});
}
}); /* document.ready */