diff --git a/src/db.lisp b/src/db.lisp index 9ad928d..390e406 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -2479,6 +2479,28 @@ Metadata are: (order-by= query '(:desc :message-index)) (fetch-single query))) + +(defun search-next-message-by-status (timeline + folder + start-status-message-index + filter-status-column + filter-status-column-value + &key (account-id nil)) + "Search the next unread message belonging +to `timeline' , `folder' and possibly `account-id', older than +`start-status-message-index'" + (let* ((filter-criteria `(:and := ,filter-status-column + ,filter-status-column-value)) + (query (make-filtered-message-select nil + timeline + folder + account-id + `(:and :> :status.message-index + ,start-status-message-index) + filter-criteria))) + (order-by= query :message-index) + (fetch-single query))) + (defun search-next-unread-message (timeline folder start-status-message-index @@ -2486,16 +2508,12 @@ Metadata are: "Search the next unread message belonging to `timeline' , `folder' and possibly `account-id', older than `start-status-message-index'" - (let* ((query (make-filtered-message-select nil - timeline - folder - account-id - `(:and :> :status.message-index - ,start-status-message-index) - `(:and := :status.redp - ,+db-false+)))) - (order-by= query :message-index) - (fetch-single query))) + (search-next-message-by-status timeline + folder + start-status-message-index + :status.redp + +db-false+ + :account-id account-id)) (defun search-next-undeleted-message (timeline folder @@ -2504,16 +2522,12 @@ to `timeline' , `folder' and possibly `account-id', older than "Search the next undeleted message belonging to `timeline' , `folder' and possibly `account-id', older than `start-status-message-index'" - (let* ((query (make-filtered-message-select nil - timeline - folder - account-id - `(:and :> :status.message-index - ,start-status-message-index) - `(:and := :status.deletedp - ,+db-false+)))) - (order-by= query :message-index) - (fetch-single query))) + (search-next-message-by-status timeline + folder + start-status-message-index + :status.deletedp + +db-false+ + :account-id account-id)) (defmacro with-add-account-id-to-query ((query query-body) account-id &body body) `(let ((,query ,query-body))