emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jeff Kowalski <jeff.kowalski@gmail.com>
To: Gustavo Barros <gusbrs.2016@gmail.com>
Cc: emacs-orgmode@gnu.org, bhavin7392@gmail.com
Subject: Re: Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)]
Date: Fri, 25 Jun 2021 20:13:18 -0700	[thread overview]
Message-ID: <CAG-eCj5Q++Xqzcr_XHhmovRO65j=4p7X5qtHeqA1c7QHX2SU9Q@mail.gmail.com> (raw)
In-Reply-To: <87fsxgd420.fsf@gmail.com>

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

While I don't have a fix for the root issue, I did have a chance to create
a lint for LOGBOOK duplicates, as you suggested.
It can be found here:
https://github.com/jeffkowalski/prelude/commit/f44b6041730469ba2094849b60d301cd94a5bed1#diff-3de035eea502a119bcdd40f4adc3d6108d4f337f827358cb2361623525682042R1199-R1251

Also below:

  (defun jeff/org-logbook-retrieve-timestamps (beg end)
    "Retrieve timestamp of all state-change entries between BEG and END."
    (save-excursion
      (let* ((reversed org-log-states-order-reversed)
             (search (if reversed 're-search-forward 're-search-backward))
             (limit (if reversed end (point)))
             (re (format
                  "^[ \t]*-[ \t]+\\(?:State \"%s\"\s+from\s+\"%s\".*%s%s\\)"
                  org-todo-regexp
                  org-todo-regexp
                  org-ts-regexp-inactive
                  (let ((value (cdr (assq 'done org-log-note-headings))))
                    (if (not value) ""
                      (concat "\\|"
                              (org-replace-escapes
                               (regexp-quote value)
                               `(("%d" . ,org-ts-regexp-inactive)
                                 ("%D" . ,org-ts-regexp)
                                 ("%s" . "\"\\S-+\"")
                                 ("%S" . "\"\\S-+\"")
                                 ("%t" . ,org-ts-regexp-inactive)
                                 ("%T" . ,org-ts-regexp)
                                 ("%u" . ".*?")
                                 ("%U" . ".*?"))))))))
             log-entries)
        (goto-char (if reversed beg end))
        (while (funcall search re limit t)
          (push (match-string-no-properties 3) log-entries))
        log-entries)))

  (defun org-lint-duplicate-logbook-timestamps (ast)
    "Report LOGBOOK entries with duplicate timestamp"
    (org-element-map ast 'drawer
      (lambda (d)
        (when (equal (org-element-property :drawer-name d) "LOGBOOK")
          (let* ((beg (org-element-property :contents-begin d))
                 (end (org-element-property :contents-end d))
                 (orig (jeff/org-logbook-retrieve-timestamps beg end))
                 (uniq (cl-remove-duplicates
                        orig
                        :test (lambda (x y) (or (null y) (equal x y)))
                        :from-end t))
                 (diff (- (length orig) (length uniq))))
            (unless (zerop diff)
              (list (org-element-property :begin d)
                    (format "LOGBOOK has %d entries with duplicate
timestamp" diff))))))))

  (add-to-list 'org-lint--checkers
               (make-org-lint-checker
                :name 'duplicate-logbook-timestamps
                :description "Report LOGBOOK entries with duplicate
timestamp"
                :categories '(properties)))


On Thu, Jun 17, 2021 at 6:16 AM Gustavo Barros <gusbrs.2016@gmail.com>
wrote:

> Thanks for confirming and for the habits info.  So that's what was
> happening with my consistency graphs.  I had indeed been noticing they
> felt "off", but I eventually reverted to 9.4.4 because of the duplicate
> entries and forgot about it.  It seems then that this got solved for me
> not by the reverting itself but by me removing the duplicate entries in
> the LOGBOOK.
>
> Would clocking reports be affected too? (I'm not personally an user of
> clocking, so I don't really know).
>
> Perhaps a "lint" for LOGBOOK duplicates would be a good idea alongside
> with the fix, so that people could go about fixing their data with a
> little more convenience?
>
> Best regards,
> Gustavo.
>

[-- Attachment #2: Type: text/html, Size: 5157 bytes --]

  reply	other threads:[~2021-06-26  3:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  2:22 Bug: Duplicate logbook entry for repeated tasks [9.4.6 (9.4.6-gab9f2a @ /home/gustavo/.emacs.d/elpa/org-9.4.6/)] Jeff Kowalski
2021-06-17 13:16 ` Gustavo Barros
2021-06-26  3:13   ` Jeff Kowalski [this message]
2021-06-26 10:53     ` Gustavo Barros
2021-06-27  2:28     ` Gustavo Barros
2021-06-27  6:31       ` Bhavin Gandhi
2021-06-27 10:28         ` Gustavo Barros
2021-06-28 17:25           ` Bhavin Gandhi
  -- strict thread matches above, loose matches on Subject: below --
2021-06-14 13:39 Gustavo Barros
2021-06-14 18:01 ` Bhavin Gandhi
2021-06-14 18:41   ` Gustavo Barros

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.orgmode.org/

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

  git send-email \
    --in-reply-to='CAG-eCj5Q++Xqzcr_XHhmovRO65j=4p7X5qtHeqA1c7QHX2SU9Q@mail.gmail.com' \
    --to=jeff.kowalski@gmail.com \
    --cc=bhavin7392@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=gusbrs.2016@gmail.com \
    /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/org-mode.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).