1
0
Fork 0

Speed up ‘oni-org-roam--books-to-read’

By doing more of the filtering in SQL rather than Emacs Lisp it got a bit
faster.
This commit is contained in:
Tom Willemse 2023-08-01 11:02:56 -07:00
parent 346f4598a5
commit cff931be7e

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0330.183039
;; Version: 2023.0728.155508
;; Package-Requires: (oni-org org-roam)
;; This program is free software; you can redistribute it and/or modify
@ -67,13 +67,13 @@
(not (string= state "FINISHED")))))
(defun oni-org-roam--books-to-read ()
(seq-filter (lambda (item)
(string= (map-elt (car item) "STATUS") "toread"))
(org-roam-db-query [:select [nodes:properties nodes:file nodes:title]
:from nodes
:left-join tags
:on (= tags:node-id nodes:id)
:where (like tag (quote "%\"book\"%"))])))
(org-roam-db-query (concat "select properties, file, title, group_concat(tag) as node_tags "
"from nodes "
"left join tags on node_id=id "
"group by id "
"having node_tags like '%%\"book\"%%' "
"and node_tags like '%%\"unread\"%%' "
"order by title")))
(defun oni-org-roam-list-books-to-read ()
(interactive)