mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
(feat)buffer: optimize reflinks fetch (#1795)
Use SQL join instead of iterating over each ref and running another sql query.
This commit is contained in:
@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## TBD
|
||||||
|
### Added
|
||||||
|
### Removed
|
||||||
|
### Changed
|
||||||
|
- [#1795](https://github.com/org-roam/org-roam/pull/1795) buffer: optimized reflinks fetch
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
## 2.1.0
|
## 2.1.0
|
||||||
### Added
|
### Added
|
||||||
- [#1709](https://github.com/org-roam/org-roam/pull/1709) added ability to specify default value in org-roam capture templates
|
- [#1709](https://github.com/org-roam/org-roam/pull/1709) added ability to specify default value in org-roam capture templates
|
||||||
|
@ -542,22 +542,20 @@ Sorts by title."
|
|||||||
|
|
||||||
(defun org-roam-reflinks-get (node)
|
(defun org-roam-reflinks-get (node)
|
||||||
"Return the reflinks for NODE."
|
"Return the reflinks for NODE."
|
||||||
(let ((refs (org-roam-db-query [:select [ref] :from refs
|
(let ((refs (org-roam-db-query [:select :distinct [refs:ref links:source links:pos links:properties]
|
||||||
:where (= node-id $s1)]
|
:from refs
|
||||||
|
:left-join links
|
||||||
|
:where (= refs:node-id $s1)
|
||||||
|
:and (= links:dest refs:ref)]
|
||||||
(org-roam-node-id node)))
|
(org-roam-node-id node)))
|
||||||
links)
|
links)
|
||||||
(pcase-dolist (`(,ref) refs)
|
(pcase-dolist (`(,ref ,source-id ,pos ,properties) refs)
|
||||||
(pcase-dolist (`(,source-id ,pos ,properties) (org-roam-db-query
|
(push (org-roam-populate
|
||||||
[:select [source pos properties]
|
(org-roam-reflink-create
|
||||||
:from links
|
:source-node (org-roam-node-create :id source-id)
|
||||||
:where (= dest $s1)]
|
:ref ref
|
||||||
ref))
|
:point pos
|
||||||
(push (org-roam-populate
|
:properties properties)) links))
|
||||||
(org-roam-reflink-create
|
|
||||||
:source-node (org-roam-node-create :id source-id)
|
|
||||||
:ref ref
|
|
||||||
:point pos
|
|
||||||
:properties properties)) links)))
|
|
||||||
links))
|
links))
|
||||||
|
|
||||||
(defun org-roam-reflinks-sort (a b)
|
(defun org-roam-reflinks-sort (a b)
|
||||||
|
Reference in New Issue
Block a user