From 623739f29de6c5fabd9eeee58a0671f62daf24cf Mon Sep 17 00:00:00 2001 From: cage Date: Sat, 14 Oct 2023 15:59:31 +0200 Subject: [PATCH] - fixed tags usage histogram. --- src/api-client.lisp | 8 ++++++++ src/db.lisp | 2 +- src/package.lisp | 3 +++ src/program-events.lisp | 8 ++++++++ src/ui-goodies.lisp | 6 +++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/api-client.lisp b/src/api-client.lisp index efacea3..e7b07cc 100644 --- a/src/api-client.lisp +++ b/src/api-client.lisp @@ -477,6 +477,14 @@ become an emty string (\"\") "" nil)))) +(defun-api-call tag-information (tag) + "Get-information about a `tag' (returns a tooter:tag object)" + (tooter:tag-information *client* tag)) + +(defun-api-call tag-history (tag) + (when-let ((tag-info (tooter:tag-information *client* tag))) + (tooter:history tag-info))) + (defun-api-call update-subscribed-tags (all-tags all-paginations &key (limit 20)) "Update all tage in the list `all-tags'" (loop diff --git a/src/db.lisp b/src/db.lisp index f57fd0f..8e9162d 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -1227,7 +1227,7 @@ than (swconf:config-purge-history-days-offset) days in the past" (from +table-tag-histogram+) (where (:and (:= :day actual-day) (:= :tag tag) - (:> :count use-count))))))) + (:< :count use-count))))))) (cond ((not entry-exists-p) (query (make-insert +table-tag-histogram+ diff --git a/src/package.lisp b/src/package.lisp index 294601d..05c6720 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1703,6 +1703,7 @@ :notify-fetched-new-tag-messages-event :tag-mark-got-messages-event :refresh-tag-window-event + :update-tags-histograms-event :update-conversations-event :change-conversation-name-event :old-name @@ -1820,6 +1821,8 @@ :update-timeline :tag->folder-name :tag-name + :tag-information + :tag-history :update-subscribed-tags :fetch-remote-status :get-remote-status diff --git a/src/program-events.lisp b/src/program-events.lisp index 120e205..5d1b5b2 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -984,6 +984,14 @@ (defmethod process-event ((object refresh-tag-window-event)) (tags-window:resync-rows-db specials:*tags-window*)) +(defclass update-tags-histograms-event (program-event) ()) + +(defmethod process-event ((object update-tags-histograms-event)) + (loop for subscribed-tag in (db:all-subscribed-tags-name :as-folder-name nil) do + (when-let ((tag-history (api-client:tag-history subscribed-tag))) + (loop for history-entry in tag-history do + (db:update-db history-entry :tag (db:folder-name->tag subscribed-tag)))))) + (defclass update-conversations-event (program-event event-with-timeline-and-folder) ()) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 80b6a73..7e2da94 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -1054,10 +1054,14 @@ It an existing file path is provided the command will refuse to run." (make-instance 'notify-fetched-new-tag-messages-event)) (update-subscribed-event (make-instance 'update-last-refresh-subscribe-tags-event)) - (refresh-window-event (make-instance 'refresh-tag-window-event))) + (update-tag-histogram-events + (make-instance 'update-tags-histograms-event)) + (refresh-window-event + (make-instance 'refresh-tag-window-event))) (push-event update-got-message-event) (push-event notify-event) (push-event update-subscribed-event) + (push-event update-tag-histogram-events) (push-event refresh-window-event)))) (notify (_ "Downloading tags messages")) (update)