1
0
Fork 0

- added clause 'into' in local fediverse query.

This commit is contained in:
cage 2024-06-16 10:41:15 +02:00
parent 824e89883a
commit 720c55e5b3
2 changed files with 42 additions and 26 deletions

View File

@ -130,10 +130,22 @@
(strcat "where " (join-with-strings (third a) " "))
""))))
(defrule fedisearch-into (and "into" fedisearch-spaces (+ (not fedisearch-blank)))
(:function (lambda (a)
(third a)))
(:text t))
(defrule fedisearch-query (? (and fedisearch-where-clause (? (and fedisearch-spaces fedisearch-into))))
(:function (lambda (a)
(list (first a) (second (second a))))))
(defun parse-search-statuses (query)
(let* ((where-clause (parse 'fedisearch-where-clause query))
(let* ((parsed (parse 'fedisearch-query query))
(where-clause (first parsed))
(destination-folder (second parsed))
(sql-query (strcat (format nil
"select * from \"~a\" ~a"
"select * from \"~a\" ~@[~a~]"
+view-search-fediverse-statuses+
where-clause))))
(db-utils:query-low-level sql-query)))
(values (db-utils:query-low-level sql-query)
destination-folder)))

View File

@ -2038,26 +2038,30 @@
(defmethod process-event ((object fediverse-local-query-event))
(with-accessors ((payload payload)) object
(loop for status-results in (fediverse-post-local-search:parse-search-statuses payload) do
(let* ((status-id (db:row-message-status-id status-results))
(multiple-value-bind (statuses destination-folder)
(fediverse-post-local-search:parse-search-statuses payload)
(let ((folder (or destination-folder
(query-results-folder-name))))
(loop for status in statuses do
(let* ((status-id (db:row-message-status-id status))
(status-row (db:find-status-id status-id)))
(when (not (db::find-status-id-folder-timeline status-id
(query-results-folder-name)
folder
db:+home-timeline+))
(setf (getf status-row :folder)
(query-results-folder-name))
folder)
(setf (getf status-row :timeline)
db:+home-timeline+)
(multiple-value-bind (query column-values)
(db-utils:insert-query db:+table-status+ status-row)
(db-utils:query-low-level query column-values)))))
(db:renumber-timeline-message-index db:+home-timeline+
(query-results-folder-name)
folder
:account-id nil)
(let ((refresh-event (make-instance 'refresh-thread-windows-event
:new-folder (query-results-folder-name)
:new-folder folder
:new-timeline db:+home-timeline+)))
(push-event refresh-event))))
(push-event refresh-event))))))
;;;; end events