iens

Manager of links to read
git clone https://git.instinctive.eu/iens.git
Log | Files | Refs | README | LICENSE

commit 91cd529fca4ded42af4901ad8a0e8168d8cf9ee0
parent 41478cfedc2630195d4e288059247cea42538074
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Tue, 13 Feb 2024 19:01:28 +0000

Command `count-selection`
Diffstat:
Msrc/iens.scm | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/iens.scm b/src/iens.scm @@ -478,6 +478,26 @@ vt100-reset)) (write-string notes)) +(define (count-selection* text id) + (write-line (string-append (if id (conc "#" id ": ") "") + "\"" text "\"")) + (write-line (conc " -> " (query fetch-value + ((if id sql sql/transient) + db + (string-append + "SELECT COUNT(id) FROM entry " + text ";")))))) + +(defcmd (count-selection . args) + "\"WHERE ...\"|selector-id ..." "Count results of a custom queries" + (if (null? args) + (query (for-each-row* count-selection*) + (sql db "SELECT text,id FROM selector;")) + (let loop ((todo args)) + (unless (null? todo) + (call-with-selector (car todo) count-selection*) + (loop (cdr todo)))))) + (defcmd (list-selection arg) "\"WHERE ...\"|selector-id" "Display a custom query as an entry list" (call-with-selector arg