mirror of
https://codeberg.org/cage/tinmop/
synced 2024-12-17 23:18:28 +01:00
- [gemini] fixed purging and refreshing posts from subscribed gemlog
- changing deleting of posts references to logical deleting (i.e. setting a boolean column to true); - fixed time threshold for purging (must be a negative integer).
This commit is contained in:
parent
0fe939ea1d
commit
6356331408
26
src/db.lisp
26
src/db.lisp
@ -557,6 +557,7 @@
|
|||||||
" snippet TEXT, "
|
" snippet TEXT, "
|
||||||
;; boolean
|
;; boolean
|
||||||
" seenp INTEGER DEFAULT 0, "
|
" seenp INTEGER DEFAULT 0, "
|
||||||
|
" deletedp INTEGER DEFAULT 0, "
|
||||||
" UNIQUE(url) ON CONFLICT FAIL"
|
" UNIQUE(url) ON CONFLICT FAIL"
|
||||||
+make-close+)))
|
+make-close+)))
|
||||||
|
|
||||||
@ -773,7 +774,7 @@ than `max-id'"
|
|||||||
(defun threshold-time (days-in-the-past)
|
(defun threshold-time (days-in-the-past)
|
||||||
"Returns a time object `days-in-the-past' days in the past"
|
"Returns a time object `days-in-the-past' days in the past"
|
||||||
(local-time:adjust-timestamp (local-time-obj-now)
|
(local-time:adjust-timestamp (local-time-obj-now)
|
||||||
(offset :day days-in-the-past)))
|
(offset :day (- (abs days-in-the-past)))))
|
||||||
|
|
||||||
(defun purge-history ()
|
(defun purge-history ()
|
||||||
"Remove expired entry in history.
|
"Remove expired entry in history.
|
||||||
@ -2890,6 +2891,8 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
|
|||||||
(from :gemlog-entries)
|
(from :gemlog-entries)
|
||||||
(where (:and (:= :gemlog-entries.seenp
|
(where (:and (:= :gemlog-entries.seenp
|
||||||
(prepare-for-db nil :to-integer t))
|
(prepare-for-db nil :to-integer t))
|
||||||
|
(:= :gemlog-entries.deletedp
|
||||||
|
(prepare-for-db nil :to-integer t))
|
||||||
(:= :gemlog-entries.gemlog-id
|
(:= :gemlog-entries.gemlog-id
|
||||||
:gemini-subscription.url))))
|
:gemini-subscription.url))))
|
||||||
:unseen-count)
|
:unseen-count)
|
||||||
@ -2897,6 +2900,8 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
|
|||||||
(from :gemlog-entries)
|
(from :gemlog-entries)
|
||||||
(where (:and (:= :gemlog-entries.seenp
|
(where (:and (:= :gemlog-entries.seenp
|
||||||
(prepare-for-db t :to-integer t))
|
(prepare-for-db t :to-integer t))
|
||||||
|
(:= :gemlog-entries.deletedp
|
||||||
|
(prepare-for-db nil :to-integer t))
|
||||||
(:= :gemlog-entries.gemlog-id
|
(:= :gemlog-entries.gemlog-id
|
||||||
:gemini-subscription.url))))
|
:gemini-subscription.url))))
|
||||||
:seen-count))
|
:seen-count))
|
||||||
@ -2963,7 +2968,9 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
|
|||||||
(join :gemini-subscription
|
(join :gemini-subscription
|
||||||
:on (:= :gemlog-entries.gemlog-id
|
:on (:= :gemlog-entries.gemlog-id
|
||||||
:gemini-subscription.url))
|
:gemini-subscription.url))
|
||||||
(where (:= :gemini-subscription.url gemlog-url))))
|
(where (:and (:= :gemini-subscription.url gemlog-url)
|
||||||
|
(:= :gemlog-entries.deletedp
|
||||||
|
(prepare-for-db nil :to-integer t))))))
|
||||||
(unordered-rows (fetch-all-rows query))
|
(unordered-rows (fetch-all-rows query))
|
||||||
(actual-rows (cond
|
(actual-rows (cond
|
||||||
(unseen-only
|
(unseen-only
|
||||||
@ -2992,14 +2999,19 @@ than `days-in-the-past' days (default: `(swconf:config-purge-cache-days-offset)'
|
|||||||
(row-post-date a)))))))
|
(row-post-date a)))))))
|
||||||
|
|
||||||
(defun delete-gemlog-entry (gemlog-url)
|
(defun delete-gemlog-entry (gemlog-url)
|
||||||
(query (delete-from +table-gemlog-entries+ (where (:= :url gemlog-url)))))
|
(query (make-update +table-gemlog-entries+
|
||||||
|
(:deletedp)
|
||||||
|
((prepare-for-db t :to-integer 1))
|
||||||
|
(where (:= :url gemlog-url)))))
|
||||||
|
|
||||||
(defun purge-seen-gemlog-entries ()
|
(defun purge-seen-gemlog-entries ()
|
||||||
"Remove expired gemlog and (seen) entries.
|
"Remove expired gemlog and (seen) entries.
|
||||||
|
|
||||||
An entry is expired if older
|
An entry is expired if older than (swconf:config-purge-history-days-offset)
|
||||||
than (swconf:config-purge-history-days-offset) days in the past"
|
days in the past"
|
||||||
(let ((treshold (threshold-time 255)))
|
(let ((treshold (threshold-time -255)))
|
||||||
(query (make-delete +table-gemlog-entries+
|
(query (make-update +table-gemlog-entries+
|
||||||
|
(:deletedp)
|
||||||
|
((prepare-for-db t :to-integer 1))
|
||||||
(:and (:= :seenp (prepare-for-db t :to-integer 1))
|
(:and (:= :seenp (prepare-for-db t :to-integer 1))
|
||||||
(:< :date (prepare-for-db treshold)))))))
|
(:< :date (prepare-for-db treshold)))))))
|
||||||
|
@ -43,11 +43,11 @@
|
|||||||
(tui:text-ellipsis (db:row-title gemlog-db-row)
|
(tui:text-ellipsis (db:row-title gemlog-db-row)
|
||||||
(truncate (/ (win-width window)
|
(truncate (/ (win-width window)
|
||||||
3)))
|
3)))
|
||||||
(when (db:row-subtitle gemlog-db-row)
|
(if (db:row-subtitle gemlog-db-row)
|
||||||
(tui:text-ellipsis (db:row-subtitle gemlog-db-row)
|
(tui:text-ellipsis (db:row-subtitle gemlog-db-row)
|
||||||
(truncate (/ (win-width window)
|
(truncate (/ (win-width window)
|
||||||
3)))
|
3)))
|
||||||
(_ "No subtitle"))
|
(_ "No subtitle"))
|
||||||
(db:row-unseen-count gemlog-db-row)
|
(db:row-unseen-count gemlog-db-row)
|
||||||
(+ (db:row-unseen-count gemlog-db-row)
|
(+ (db:row-unseen-count gemlog-db-row)
|
||||||
(db:row-seen-count gemlog-db-row))))
|
(db:row-seen-count gemlog-db-row))))
|
||||||
|
Loading…
Reference in New Issue
Block a user