unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: stefan@marxist.se
Cc: 50686@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca
Subject: bug#50686: Show number of downloads on packages on GNU ELPA/NonGNU ELPA
Date: Fri, 8 Sep 2023 03:30:25 -0500	[thread overview]
Message-ID: <985acef0-69f1-39c3-1354-9a49149c9df9@alphapapa.net> (raw)
In-Reply-To: <CADwFkm=CpozcFkd1XRn_BE56kTmt1U2JP00rcAdpXG2Dd3fhWg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

If it helps, here's a first pass at a regexp and function to parse the 
logs into download counts per package file.

--Adam

[-- Attachment #2: elpa-stats.el --]
[-- Type: text/x-emacs-lisp, Size: 1457 bytes --]

(defconst elpa-download-log-line-re
  (rx (group (1+ (or digit "." ":")))
      " - - "
      "[" (group (repeat 2 digit) "/" (repeat 3 alpha) "/" (repeat 4 digit)
                 ":" (repeat 2 digit) ":" (repeat 2 digit) ":" (repeat 2 digit)
                 " " (or "+" "-") (repeat 4 digit)) "]"
      ;; ;; HTTP query:
      " \"" (group (1+ alpha))         ; method
      " " (group (1+ (not (any blank)))) ; path
      " " "HTTP/" (1+ (or alnum ".")) "\"" ; protocol
      " " (group (1+ digit))               ; status code
      " " (group (1+ digit))               ; size
      " \"-\" "                            ; ?
      "\"" (group (1+ (not (any "\"")))) "\""))

(defun elpa-log-to-package-stats (log-string)
  "Return alist of (PACKAGE . DOWNLOADS) seen in LOG-STRING.
    LOG-STRING is an HTTP download log."
  (let ((stats (make-hash-table :test #'equal)))
    (with-temp-buffer
      (insert log-string)
      (goto-char (point-min))
      (cl-loop while (re-search-forward elpa-download-log-line-re nil t)
               for file = (match-string 4)
               when (string-match-p (rx bos "/packages/" (1+ anything) (or ".tar" ".el") eos)
                                    file)
               do (if (gethash file stats)
                      (cl-incf (gethash file stats))
                    (setf (gethash file stats) 1))))
    (map-into stats 'alist)))

;; (("/packages/seq-2.23.tar" . 1) ("/packages/let-alist-1.0.6.el" . 1))

  reply	other threads:[~2023-09-08  8:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-19 21:13 bug#50686: Show number of downloads on packages on GNU ELPA/NonGNU ELPA Stefan Kangas
2021-09-20  4:35 ` Eli Zaretskii
2021-09-20  5:54   ` Stefan Kangas
2021-09-20  6:22 ` Lars Ingebrigtsen
2023-09-07 22:05   ` Stefan Kangas
2023-09-08  8:30     ` Adam Porter [this message]
2024-03-05 23:58       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-06  0:22         ` Adam Porter
2024-03-06  2:57           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-06  5:04             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-08 23:20               ` Adam Porter
2024-03-09 14:37                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-11 20:07                   ` Adam Porter
2024-03-11 20:28                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-11 20:55                       ` Adam Porter
2024-03-11 22:13                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-01 19:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-02 13:39   ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=985acef0-69f1-39c3-1354-9a49149c9df9@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=50686@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).