Add a basic verify method for plist-group backends
This commit is contained in:
parent
a4617f7066
commit
8e94af2f32
13
TODO.org
13
TODO.org
|
@ -835,13 +835,14 @@ Command to delete the interval currently being recorded. (bind to 'k')
|
|||
** fix handling of tagged alist group values :bug:
|
||||
** put each list element on its own line if length of list exceeds fill-column :feature:
|
||||
|
||||
* verify command :feature:
|
||||
* verify command [20%] :feature:
|
||||
With different checks, for different levels of speed/thoroughness -
|
||||
1. (plist group) Sequence of plist group dates
|
||||
2. Intersecting timestamps
|
||||
3. Sequence of records
|
||||
4. (plist group) Midnight spanning interval check (first and last intervals)
|
||||
5. (plist group) Check that plist timestamps have the correct date. Only applicable [[dates-in-timestamps][as long as they have a date.]]
|
||||
1. [X] (plist group) Sequence of plist group dates
|
||||
2. [ ] Check that every record (except the last) has a =:stop=
|
||||
3. [ ] Intersecting timestamps
|
||||
4. [ ] Sequence of records
|
||||
5. [ ] (plist group) Midnight spanning interval check (first and last intervals)
|
||||
6. [ ] (plist group) Check that plist timestamps have the correct date. Only applicable [[dates-in-timestamps][as long as they have a date.]]
|
||||
|
||||
* format changes
|
||||
** multiple intervals per record :feature:
|
||||
|
|
|
@ -952,7 +952,10 @@ backend file).")
|
|||
|
||||
;; [[file:chronometrist.org::*verify][verify:1]]
|
||||
(cl-defgeneric chronometrist-verify (backend)
|
||||
"Check BACKEND for errors in data.")
|
||||
"Check BACKEND for errors in data.
|
||||
Return nil if no errors are found.
|
||||
|
||||
If an error is found, return (LINE-NUMBER . COLUMN-NUMBER) for file-based backends.")
|
||||
;; verify:1 ends here
|
||||
|
||||
;; [[file:chronometrist.org::*on-file-path-change][on-file-path-change:1]]
|
||||
|
@ -1766,6 +1769,27 @@ Return value is either a list in the form
|
|||
(puthash old-date nil hash-table))))
|
||||
;; on-remove:1 ends here
|
||||
|
||||
;; [[file:chronometrist.org::*verify][verify:1]]
|
||||
(cl-defmethod chronometrist-verify ((backend chronometrist-plist-group-backend))
|
||||
(with-slots (file hash-table) backend
|
||||
;; incorrectly ordered groups check
|
||||
(chronometrist-loop-sexp-file for group in file
|
||||
with old-date-iso with old-date-unix
|
||||
with new-date-iso with new-date-unix
|
||||
with last-plist
|
||||
;; while (not (bobp))
|
||||
do (setq new-date-iso (cl-first group)
|
||||
new-date-unix (parse-iso8601-time-string new-date-iso))
|
||||
when (and old-date-unix
|
||||
(time-less-p old-date-unix
|
||||
new-date-unix))
|
||||
do (cl-return (format "%s appears before %s on line %s"
|
||||
new-date-iso old-date-iso (line-number-at-pos)))
|
||||
else do (setq old-date-iso new-date-iso
|
||||
old-date-unix new-date-unix)
|
||||
finally return "Yay, no errors! (...that I could find 💀)")))
|
||||
;; verify:1 ends here
|
||||
|
||||
;; [[file:chronometrist.org::*latest-record][latest-record:1]]
|
||||
(cl-defmethod chronometrist-latest-record ((backend chronometrist-plist-group-backend))
|
||||
(cl-first (last (chronometrist-latest-date-records backend))))
|
||||
|
|
|
@ -1579,7 +1579,10 @@ backend file).")
|
|||
***** verify :generic:function:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defgeneric chronometrist-verify (backend)
|
||||
"Check BACKEND for errors in data.")
|
||||
"Check BACKEND for errors in data.
|
||||
Return nil if no errors are found.
|
||||
|
||||
If an error is found, return (LINE-NUMBER . COLUMN-NUMBER) for file-based backends.")
|
||||
#+END_SRC
|
||||
|
||||
***** on-file-path-change :generic:function:
|
||||
|
@ -2698,6 +2701,28 @@ Return value is either a list in the form
|
|||
(puthash old-date nil hash-table))))
|
||||
#+END_SRC
|
||||
|
||||
**** verify :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-verify ((backend chronometrist-plist-group-backend))
|
||||
(with-slots (file hash-table) backend
|
||||
;; incorrectly ordered groups check
|
||||
(chronometrist-loop-sexp-file for group in file
|
||||
with old-date-iso with old-date-unix
|
||||
with new-date-iso with new-date-unix
|
||||
with last-plist
|
||||
;; while (not (bobp))
|
||||
do (setq new-date-iso (cl-first group)
|
||||
new-date-unix (parse-iso8601-time-string new-date-iso))
|
||||
when (and old-date-unix
|
||||
(time-less-p old-date-unix
|
||||
new-date-unix))
|
||||
do (cl-return (format "%s appears before %s on line %s"
|
||||
new-date-iso old-date-iso (line-number-at-pos)))
|
||||
else do (setq old-date-iso new-date-iso
|
||||
old-date-unix new-date-unix)
|
||||
finally return "Yay, no errors! (...that I could find 💀)")))
|
||||
#+END_SRC
|
||||
|
||||
**** extended protocol
|
||||
***** latest-record :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
|
Reference in New Issue