branch: elpa-admin commit 0ee51630cef5dc8ee4edc47f23fb113c5ac3e521 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
* elpa-admin.el (elpaa--wsl-read): Improve info messages Add sync/build-failure special cases. Pass the whole line as well to `fn`. (elpaa--wsl-one-file): Include the whole line in the information message. (elpaa--wsl-scores): Reindent. --- elpa-admin.el | 59 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index 1793bd8c70..e8c4114ec8 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -2080,7 +2080,8 @@ arbitrary code." (if (not (looking-at elpaa--wsl-line-re)) (message "Unrecognized log line: %s" (buffer-substring (point) (line-end-position))) - (let* ((timestr (match-string 1)) + (let* ((line (match-string 0)) + (timestr (match-string 1)) (file (match-string 2)) (timestr (if (string-match "/\\([^/]*\\)/\\([^/:]*\\):" timestr) @@ -2100,53 +2101,55 @@ arbitrary code." (+ (or digit ".")) (* (or "pre" "beta" "alpha" "snapshot") (* (or digit ".")))) - "readme")) + "readme" + "sync-failure" + "build-failure")) "." (or "tar" "txt" "el" "html")) file) (match-string 1 file)))) - (funcall fn time pkg file))))) + (funcall fn time pkg file line))))) (forward-line 1)))) (defun elpaa--wsl-one-file (logfile stats) (elpaa--wsl-read logfile ;; Keep a counter of accesses indexed by package and week. - (lambda (time pkg file) + (lambda (time pkg file line) (let* ((secs (time-convert time 'integer)) (week (/ secs 3600 24 7)) (old (gethash pkg stats))) (unless old - (message "New package: %S %S %S" time pkg file)) + (message "New package: %S %S %S %S" time pkg file line)) (cl-incf (alist-get week (gethash pkg stats) 0)))))) (defvar elpaa--wsl-directory "/var/log/apache2/") (defun elpaa--wsl-scores (table) (let ((scores-by-week ())) - (maphash (lambda (pkg data) - (when (and pkg (not (string-match "/" pkg))) - (pcase-dolist (`(,week . ,count) data) - (push (cons count pkg) (alist-get week scores-by-week))))) - table) - ;; For each week, we sort packages by number of downloads, to - ;; compute their percentile ranking. - ;; FIXME: We don't take into account that several (many?) packages can - ;; have the same number of downloads, in which case their relative ranking - ;; (within the equiv class) is a lie. - (dolist (scores scores-by-week) - (setf (cdr scores) - (nreverse (mapcar #'cdr (sort (cdr scores) - #'car-less-than-car))))) - (let ((score-table (make-hash-table :test 'equal))) - (pcase-dolist (`(,week . ,pkgs) scores-by-week) - (let* ((total (length pkgs)) - (rest total)) - (dolist (pkg pkgs) - (setq rest (1- rest)) - (let ((percentile (/ (* 100 rest) total))) - (push (cons week percentile) (gethash pkg score-table)))))) - score-table))) + (maphash (lambda (pkg data) + (when (and pkg (not (string-match "/" pkg))) + (pcase-dolist (`(,week . ,count) data) + (push (cons count pkg) (alist-get week scores-by-week))))) + table) + ;; For each week, we sort packages by number of downloads, to + ;; compute their percentile ranking. + ;; FIXME: We don't take into account that several (many?) packages can + ;; have the same number of downloads, in which case their relative ranking + ;; (within the equiv class) is a lie. + (dolist (scores scores-by-week) + (setf (cdr scores) + (nreverse (mapcar #'cdr (sort (cdr scores) + #'car-less-than-car))))) + (let ((score-table (make-hash-table :test 'equal))) + (pcase-dolist (`(,week . ,pkgs) scores-by-week) + (let* ((total (length pkgs)) + (rest total)) + (dolist (pkg pkgs) + (setq rest (1- rest)) + (let ((percentile (/ (* 100 rest) total))) + (push (cons week percentile) (gethash pkg score-table)))))) + score-table))) (defun elpaa--wsl-collect () (let* ((stats (elpaa--form-from-file-contents elpaa--wsl-stats-file))