[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnosis a8bd341f3d 5/8: Optimize dashboard homepage perform
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnosis a8bd341f3d 5/8: Optimize dashboard homepage performance |
Date: |
Thu, 7 Nov 2024 04:00:32 -0500 (EST) |
branch: elpa/gnosis
commit a8bd341f3d2cf3670f9bc6f448348375661e970d
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>
Optimize dashboard homepage performance
* Optimize homepage performance by reducing emacsql queries.
---
gnosis.el | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/gnosis.el b/gnosis.el
index 9e7325fbdf..acc4bef601 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1499,9 +1499,9 @@ well."
"Return overdue notes for current DATE.
Optionally, provide NOTE-IDS of which the overdue ones will be returned."
- (cl-loop for note in (or note-ids (gnosis-review-get-due-notes))
- when (gnosis-review-note-overdue-p note)
- collect note))
+ (cl-loop for note in (or note-ids (gnosis-review-get--due-notes))
+ when (not (equal (cadr note) (gnosis-algorithm-date)))
+ collect (car note)))
(defun gnosis-review-get-due-notes--no-overdue (&optional note-ids)
"Return due notes, without overdue.
@@ -2310,8 +2310,11 @@ If entry for DATE does not exist, it will be created.
Defaults to current date."
(cl-assert (listp date) nil "Date must be a list.")
(let* ((date (or date (gnosis-algorithm-date)))
- (reviewed-total (car (gnosis-select 'reviewed-total 'activity-log `(=
date ',date) t)))
- (reviewed-new (or (car (gnosis-select 'reviewed-new 'activity-log `(=
date ',date) t)) 0)))
+ (date-log (gnosis-select
+ '[date reviewed-total reviewed-new] 'activity-log
+ `(= date ',(gnosis-algorithm-date)) t))
+ (reviewed-total (cadr date-log))
+ (reviewed-new (or (caddr date-log) 0)))
(or reviewed-total
(progn
;; Using reviewed-new instead of hardcoding 0 just to not mess up
tests.
@@ -2687,7 +2690,8 @@ Skips days where no note was reviewed."
(defun gnosis-dashboard-output-note (id)
"Output contents for note with ID, formatted for gnosis dashboard."
- (cl-loop for item in (append (gnosis-select '[main options answer tags type]
'notes `(= id ,id) t)
+ (cl-loop for item in (append (gnosis-select
+ '[main options answer tags type] 'notes `(= id
,id) t)
(gnosis-select 'suspend 'review-log `(= id ,id)
t))
if (listp item)
collect (mapconcat #'identity item ",")
@@ -3033,8 +3037,9 @@ DASHBOARD-TYPE: either 'Notes' or 'Decks' to display the
respective dashboard."
"Launch gnosis dashboard."
(interactive)
(delete-other-windows)
- (let ((buffer-name gnosis-dashboard-buffer-name)
- (due-notes (gnosis-review-get-due-notes)))
+ (let* ((buffer-name gnosis-dashboard-buffer-name)
+ (due-log (gnosis-review-get--due-notes))
+ (due-note-ids (mapcar #'car due-log)))
(when (get-buffer buffer-name)
(kill-buffer buffer-name)) ;; Kill the existing buffer if it exists
(let ((buffer (get-buffer-create buffer-name)))
@@ -3058,26 +3063,26 @@ DASHBOARD-TYPE: either 'Notes' or 'Decks' to display
the respective dashboard."
(insert (gnosis-center-string
(format "Due notes: %s (Overdue: %s)"
(propertize
- (number-to-string (length due-notes))
+ (number-to-string (length due-note-ids))
'face 'error)
(propertize
(number-to-string
- (length (gnosis-review-get-overdue-notes due-notes)))
+ (length (gnosis-review-get-overdue-notes)))
'face 'warning))))
(insert "\n\n")
(insert (gnosis-center-string
- (format "Daily Average: %s"
- (propertize
- (number-to-string
(gnosis-dashboard-output-average-rev))
- 'face 'font-lock-type-face))))
+ (format "Daily Average: %s"
+ (propertize
+ (number-to-string
(gnosis-dashboard-output-average-rev))
+ 'face 'font-lock-type-face))))
(insert "\n")
(insert (gnosis-center-string
- (format "Current streak: %s days"
- (propertize
- (number-to-string
- (gnosis-dashboard--streak
- (gnosis-select 'date 'activity-log '1=1 t)))
- 'face 'success))))
+ (format "Current streak: %s days"
+ (propertize
+ (number-to-string
+ (gnosis-dashboard--streak
+ (gnosis-select 'date 'activity-log '1=1 t)))
+ 'face 'success))))
(insert "\n\n"))
(pop-to-buffer-same-window buffer)
(goto-char (point-min))
- [nongnu] elpa/gnosis updated (ce54993dc3 -> 5ab8ef8ca7), ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis 596ab975d6 2/8: Remove gnosis-review-note-overdue-p, ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis 6fad435b9a 6/8: gnosis-face-cloze: Use highlight instead of ffap., ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis a8bd341f3d 5/8: Optimize dashboard homepage performance,
ELPA Syncer <=
- [nongnu] elpa/gnosis c77f6787d1 4/8: Fix indentation, ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis 7f6dd4e2b0 1/8: validate-custom-values: Update error messages., ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis 21d5498e8d 3/8: Refactor review-get-due-notes, ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis 5ab8ef8ca7 8/8: Update gitignore, ELPA Syncer, 2024/11/07
- [nongnu] elpa/gnosis bfce6f9467 7/8: Version bump: 0.4.7, ELPA Syncer, 2024/11/07