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 right rem acc)
(funcall scan rem (append acc (list cur)))))
acc))))
(unless right acc)))))
(funcall scan contents)))
#+END_SRC
**** 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
(left (nd/org-element-split-linebreak contents))
(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
(org-element-interpret-data left))))
(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)
;; get time recorded based on note type
(when note-type
(set-match-data note-match)
(setq time-index
(cond
@ -3113,7 +3116,7 @@ ARCHIVE-FILE-PATH is the path to the archive file."
((memq note-type '(reschedule delschedule redeadline deldeadline)) 3)
((eq note-type 'state) 5)
(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
(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
entry-file-offset
time-logged
;; TODO add contents
nil))
note))
;; insert into auxiliary logging tables
(when note-type
(cond
((eq note-type 'state)
(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))
;; 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 ()
"Transfer archive files to sqlite database."