Compare commits

...

2 Commits

Author SHA1 Message Date
Jethro Kuan
82733e133a (fix)buffer: skip backlinks where file no longer exists
This is a fix to #1763, and an alternative to #1765. The rationale for
not running a db-sync on buffer redisplay is that this is run on
`post-command-hook` and needs to be fast.
2021-08-21 16:59:34 +08:00
Jethro Kuan
858f531d96 (feat)buffer: optimize reflinks fetch (#1795)
Use SQL join instead of iterating over each ref and running another sql query.
2021-08-21 16:18:41 +08:00
2 changed files with 22 additions and 14 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## TBD
### Added
### Removed
### Changed
- [#1795](https://github.com/org-roam/org-roam/pull/1795) buffer: optimized reflinks fetch
### Fixed
## 2.1.0
### Added
- [#1709](https://github.com/org-roam/org-roam/pull/1709) added ability to specify default value in org-roam capture templates

View File

@@ -345,6 +345,8 @@ the same time:
from SOURCE-NODE's file for the link (that references the
other node) at POINT. Acts a child section of the previous
one."
(unless (file-exists-p (org-roam-node-file source-node))
(cl-return-from org-roam-node-insert-section))
(magit-insert-section section (org-roam-node-section)
(let ((outline (if-let ((outline (plist-get properties :outline)))
(mapconcat #'org-link-display-format outline " > ")
@@ -542,22 +544,20 @@ Sorts by title."
(defun org-roam-reflinks-get (node)
"Return the reflinks for NODE."
(let ((refs (org-roam-db-query [:select [ref] :from refs
:where (= node-id $s1)]
(let ((refs (org-roam-db-query [:select :distinct [refs:ref links:source links:pos links:properties]
:from refs
:left-join links
:where (= refs:node-id $s1)
:and (= links:dest refs:ref)]
(org-roam-node-id node)))
links)
(pcase-dolist (`(,ref) refs)
(pcase-dolist (`(,source-id ,pos ,properties) (org-roam-db-query
[:select [source pos properties]
:from links
:where (= dest $s1)]
ref))
(push (org-roam-populate
(org-roam-reflink-create
:source-node (org-roam-node-create :id source-id)
:ref ref
:point pos
:properties properties)) links)))
(pcase-dolist (`(,ref ,source-id ,pos ,properties) refs)
(push (org-roam-populate
(org-roam-reflink-create
:source-node (org-roam-node-create :id source-id)
:ref ref
:point pos
:properties properties)) links))
links))
(defun org-roam-reflinks-sort (a b)