Skip to content

Commit

Permalink
Fix: time based sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Apr 30, 2024
1 parent d8f217c commit f2ae8ef
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions org-roam-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ DOCSTRING is the documentation string to use for the function."
`(lambda (node1 node2)
(,comparison-function-name (,getter node1) (,getter node2))))))

(defun org-roam-ql--sort-time-less (val1 val2)
"Sort based on time-less-p."
(if (or (null val1) (null val2))
nil
(time-less-p (org-roam-ql--time-convert-to-ts val1)
(org-roam-ql--time-convert-to-ts val2))))

;; *****************************************************************************
;; org-roam-ql mode and functions to build them and operate on them
;; *****************************************************************************
Expand Down Expand Up @@ -1087,10 +1094,10 @@ Can be used in the minibuffer or when writting querries."
("file-title" . string<)
("level" . <)
("point" . <)
("scheduled" . time-less-p)
("deadline" . time-less-p)
("file-atime" . time-less-p)
("file-mtime" . time-less-p)))
("scheduled" . org-roam-ql--sort-time-less)
("deadline" . org-roam-ql--sort-time-less)
("file-atime" . org-roam-ql--sort-time-less)
("file-mtime" . org-roam-ql--sort-time-less)))
(org-roam-ql--sort-function-for-slot (car sort-function) (cdr sort-function)))

(provide 'org-roam-ql)
Expand Down

0 comments on commit f2ae8ef

Please sign in to comment.