From cff931be7e7239dbb5c8809312e91e5a18b6ed27 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 1 Aug 2023 11:02:56 -0700 Subject: [PATCH] =?UTF-8?q?Speed=20up=20=E2=80=98oni-org-roam--books-to-re?= =?UTF-8?q?ad=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By doing more of the filtering in SQL rather than Emacs Lisp it got a bit faster. --- oni-org-roam.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/oni-org-roam.el b/oni-org-roam.el index a2feefa..efee57e 100644 --- a/oni-org-roam.el +++ b/oni-org-roam.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; 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)