fixed tags insertion sql error
This commit is contained in:
parent
c602ad7081
commit
fd3993edf2
68
conf.org
68
conf.org
|
@ -2838,7 +2838,8 @@ ACC is treated as a set; therefore no duplicates are retained."
|
||||||
(let ((parent-hl (nd/org-element-get-parent-headline obj)))
|
(let ((parent-hl (nd/org-element-get-parent-headline obj)))
|
||||||
(if parent-hl
|
(if parent-hl
|
||||||
(let* ((tags (org-element-property :tags parent-hl))
|
(let* ((tags (org-element-property :tags parent-hl))
|
||||||
(i-tags (split-string (org-element-property :ARCHIVE_ITAGS parent-hl)))
|
(i-tags (org-element-property :ARCHIVE_ITAGS parent-hl))
|
||||||
|
(i-tags (when i-tags (split-string i-tags)))
|
||||||
(all-tags (delete-dups (append acc tags i-tags))))
|
(all-tags (delete-dups (append acc tags i-tags))))
|
||||||
(nd/org-element-get-parent-tags parent-hl all-tags))
|
(nd/org-element-get-parent-tags parent-hl all-tags))
|
||||||
acc)))
|
acc)))
|
||||||
|
@ -2991,7 +2992,7 @@ These are the main functions to populate the db.
|
||||||
ARCHIVE-FILE-PATH is the file path to the currently parsed archive file."
|
ARCHIVE-FILE-PATH is the file path to the currently parsed archive file."
|
||||||
(let* ((headline-file-offset (org-element-property :begin headline))
|
(let* ((headline-file-offset (org-element-property :begin headline))
|
||||||
(archive-tree-path (nd/org-element-get-parent-tree headline))
|
(archive-tree-path (nd/org-element-get-parent-tree headline))
|
||||||
;; headline table
|
;; headline table data
|
||||||
(source-file-path (nd/org-element-property-inherited :ARCHIVE_FILE headline))
|
(source-file-path (nd/org-element-property-inherited :ARCHIVE_FILE headline))
|
||||||
(source-tree-path (nd/org-element-property-inherited :ARCHIVE_OLPATH headline))
|
(source-tree-path (nd/org-element-property-inherited :ARCHIVE_OLPATH headline))
|
||||||
(headline-text (org-element-property :raw-value headline))
|
(headline-text (org-element-property :raw-value headline))
|
||||||
|
@ -3002,34 +3003,41 @@ ARCHIVE-FILE-PATH is the file path to the currently parsed archive file."
|
||||||
(keyword (org-element-property :todo-keyword headline))
|
(keyword (org-element-property :todo-keyword headline))
|
||||||
(effort (org-element-property :EFFORT headline))
|
(effort (org-element-property :EFFORT headline))
|
||||||
(priority (org-element-property :priority headline))
|
(priority (org-element-property :priority headline))
|
||||||
(headline-data (list archive-file-path
|
tags table data
|
||||||
headline-file-offset
|
|
||||||
archive-tree-path
|
|
||||||
source-file-path
|
|
||||||
source-tree-path
|
|
||||||
headline-text
|
|
||||||
time-created
|
|
||||||
time-closed
|
|
||||||
time-scheduled
|
|
||||||
time-deadline
|
|
||||||
keyword
|
|
||||||
effort
|
|
||||||
priority
|
|
||||||
;; TODO add contents
|
|
||||||
nil))
|
|
||||||
;; tags table
|
|
||||||
(tags (org-element-property :tags headline))
|
(tags (org-element-property :tags headline))
|
||||||
(i-tags (org-element-property :ARCHIVE_ITAGS headline))
|
(i-tags (org-element-property :ARCHIVE_ITAGS headline))
|
||||||
(insert-tags (lambda (tags afp hfo inh)
|
(i-tags (when i-tags (split-string i-tags)))
|
||||||
(while tags
|
(insert-tags
|
||||||
(nd/sql-insert nd/org-sqlite-db-path
|
(lambda (tags archive-file-path headline-file-offset inherited)
|
||||||
"tags"
|
(while tags
|
||||||
(list afp hfo (car tags) inh))
|
(nd/sql-insert nd/org-sqlite-db-path
|
||||||
(setq tags (cdr tags))))))
|
"tags"
|
||||||
|
(list archive-file-path
|
||||||
|
headline-file-offset
|
||||||
|
(car tags)
|
||||||
|
inherited))
|
||||||
|
(setq tags (cdr tags))))))
|
||||||
|
|
||||||
|
;; (unless source-file-path (print headline-text))))
|
||||||
|
(nd/sql-insert nd/org-sqlite-db-path
|
||||||
|
"headlines"
|
||||||
|
(list archive-file-path
|
||||||
|
headline-file-offset
|
||||||
|
archive-tree-path
|
||||||
|
source-file-path
|
||||||
|
source-tree-path
|
||||||
|
headline-text
|
||||||
|
time-created
|
||||||
|
time-closed
|
||||||
|
time-scheduled
|
||||||
|
time-deadline
|
||||||
|
keyword
|
||||||
|
effort
|
||||||
|
priority
|
||||||
|
;; TODO add contents
|
||||||
|
nil))
|
||||||
|
|
||||||
(nd/sql-insert nd/org-sqlite-db-path "headlines" headline-data)
|
|
||||||
(funcall insert-tags tags archive-file-path headline-file-offset 0)
|
(funcall insert-tags tags archive-file-path headline-file-offset 0)
|
||||||
(when i-tags (setq i-tags (split-string i-tags)))
|
|
||||||
;; retrieve parent tags if we want inheritance
|
;; retrieve parent tags if we want inheritance
|
||||||
(when nd/org-sql-use-tag-inheritance
|
(when nd/org-sql-use-tag-inheritance
|
||||||
(setq i-tags (nd/org-element-get-parent-tags headline i-tags)))
|
(setq i-tags (nd/org-element-get-parent-tags headline i-tags)))
|
||||||
|
@ -3165,10 +3173,10 @@ ARCHIVE-FILE-PATH is the path to the archive file."
|
||||||
|
|
||||||
(defun nd/org-archive-to-db ()
|
(defun nd/org-archive-to-db ()
|
||||||
"Transfer archive files to sqlite database."
|
"Transfer archive files to sqlite database."
|
||||||
(let* ((db nd/org-sqlite-db-path)
|
(let* ((rxv-path (expand-file-name "general.org_archive" org-directory))
|
||||||
(rxv-path (expand-file-name "test.org_archive" org-directory))
|
(tree (with-current-buffer (find-file-noselect rxv-path)
|
||||||
(tree (with-current-buffer (find-file-noselect rxv-path)
|
(org-element-parse-buffer))))
|
||||||
(org-element-parse-buffer))))
|
|
||||||
(org-element-map tree 'headline
|
(org-element-map tree 'headline
|
||||||
(lambda (h) (nd/org-element-header-to-sql h rxv-path)))
|
(lambda (h) (nd/org-element-header-to-sql h rxv-path)))
|
||||||
(org-element-map tree 'clock
|
(org-element-map tree 'clock
|
||||||
|
|
Loading…
Reference in New Issue