added note to logbook data in org sql db

This commit is contained in:
ndwarshuis 2018-12-25 02:23:40 -05:00
parent f78b3882ce
commit c602ad7081
1 changed files with 42 additions and 39 deletions

View File

@ -2865,7 +2865,7 @@ If RIGHT is t, get the right half instead of the left."
(if (equal 'line-break (org-element-type cur)) (if (equal 'line-break (org-element-type cur))
(if right rem acc) (if right rem acc)
(funcall scan rem (append acc (list cur))))) (funcall scan rem (append acc (list cur)))))
acc)))) (unless right acc)))))
(funcall scan contents))) (funcall scan contents)))
#+END_SRC #+END_SRC
**** org sql constants and variables **** org sql constants and variables
@ -3098,6 +3098,8 @@ ARCHIVE-FILE-PATH is the path to the archive file."
;; split entry into right / left components via linebreak ;; split entry into right / left components via linebreak
(left (nd/org-element-split-linebreak contents)) (left (nd/org-element-split-linebreak contents))
(right (nd/org-element-split-linebreak contents t)) (right (nd/org-element-split-linebreak contents t))
(note (string-trim (substring-no-properties
(org-element-interpret-data right))))
(entry-str (string-trim (substring-no-properties (entry-str (string-trim (substring-no-properties
(org-element-interpret-data left)))) (org-element-interpret-data left))))
(note-parsed (nd/org-logbook-match-entry entry-str)) (note-parsed (nd/org-logbook-match-entry entry-str))
@ -3106,6 +3108,7 @@ ARCHIVE-FILE-PATH is the path to the archive file."
time-index time-logged logbook-data) time-index time-logged logbook-data)
;; get time recorded based on note type ;; get time recorded based on note type
(when note-type
(set-match-data note-match) (set-match-data note-match)
(setq time-index (setq time-index
(cond (cond
@ -3113,7 +3116,7 @@ ARCHIVE-FILE-PATH is the path to the archive file."
((memq note-type '(reschedule delschedule redeadline deldeadline)) 3) ((memq note-type '(reschedule delschedule redeadline deldeadline)) 3)
((eq note-type 'state) 5) ((eq note-type 'state) 5)
(t (error (concat "Unknown type: " (symbol-name note-type)))))) (t (error (concat "Unknown type: " (symbol-name note-type))))))
(setq time-logged (match-string time-index entry-str)) (setq time-logged (match-string time-index entry-str)))
;; insert into general logbook table first ;; insert into general logbook table first
(nd/sql-insert nd/org-sqlite-db-path (nd/sql-insert nd/org-sqlite-db-path
@ -3122,10 +3125,10 @@ ARCHIVE-FILE-PATH is the path to the archive file."
headline-file-offset headline-file-offset
entry-file-offset entry-file-offset
time-logged time-logged
;; TODO add contents note))
nil))
;; insert into auxiliary logging tables ;; insert into auxiliary logging tables
(when note-type
(cond (cond
((eq note-type 'state) ((eq note-type 'state)
(let* ((state-old (or (match-string 3 entry-str) (let* ((state-old (or (match-string 3 entry-str)
@ -3158,7 +3161,7 @@ ARCHIVE-FILE-PATH is the path to the archive file."
((memq note-type '(done refile note)) (ignore)) ((memq note-type '(done refile note)) (ignore))
;; this shouldn't happen ;; this shouldn't happen
(t (error (concat "Unknown entry type: " (symbol-name note-type))))))))) (t (error (concat "Unknown entry type: " (symbol-name note-type))))))))))
(defun nd/org-archive-to-db () (defun nd/org-archive-to-db ()
"Transfer archive files to sqlite database." "Transfer archive files to sqlite database."