Repository navigation
Enhancement: Add +/- syntax, (w)eek (m)onth (y)ear, and time support to query :inputs - #8387
Conversation
logseq-cldwalker
left a comment
There was a problem hiding this comment.
@bendyorke Great work on these input enhancements with date-time math! Back to you for some feedback and to get CI to green
Let me know if the namespaces are too abstract, I'm open to changing the inputs to something more readable like +3d-journal or :+3d-journal-day or +3d-from-journal-day, but none of those read right to me.
I find the emphasis on date math first more readable as suggested by #7866. But maybe having the terser +/- changes that. How about we ask non-engineers about it? If we do decide to put the date-time type first, I'd advocate for - as the separator over / as the latter seems less readable
| (let [relative-to (case (or (namespace input) "today") | ||
| "today" (t/today)) | ||
| [_ offset-direction offset offset-unit offset-ms?] (re-find #"^([+-])(\d+)([dwmy])(-ms)?$" (name input)) | ||
| offset-fn (case offset-direction "+" t/plus "-" t/minus) |
There was a problem hiding this comment.
I'm digging the explicitness of the syntax we agreed to. This sets us up nicely in the future to support chaining these down the road :)
There was a problem hiding this comment.
What do you mean by chaining these?
There was a problem hiding this comment.
Don't want to scope creep this PR hehe, but down the road we could get asks to add or subtract multiple date ranges so +1w+1d or +1y-1w would naturally fit
|
@bendyorke Changed title since PR titles get used in changelogs so we try to make them as readable for users as possible. Feel free to reword |
|
New PR title is better than I could have come up with 😂 good to know they're used in changelogs, I'll try to be more explicit in the future. Please feel free to rename anytime you'd like a change, I appreciate it! |
|
@logseq-cldwalker I think I've addressed all of your concerns. LMK if there's anything else, once this get's merged in I'll update the docs graph with info about these :D |
Sweet. Taking a look. Can you get CI to green in the meantime? There's a new version of |
logseq-cldwalker
left a comment
There was a problem hiding this comment.
@bendyorke Thanks for addressing feedback and adding time syntax as well! One product question on the new feature and waiting for a green CI
| - end: will return the time at the end of the day [23:59:59.999] | ||
| - HHMM: will return the specified time at the turn of the minute [HH:MM:00.000] | ||
| - HHMMSS: will return the specified time at the turm of the second [HH:MM:SS.000] | ||
| - HHMMSSmmm: will return the specified time at the turn of the millisecond [HH:MM:SS.mmm] |
There was a problem hiding this comment.
"Not it" for millisecond bugs 😛
| ;; :Xd, :Xd-before, :Xd-before-ms, :Xd-after, :Xd-after-ms | ||
| (resolve-keyword-input db (old->new-relative-date-format input) opts)) | ||
| (re-find #"^[+-]\d+[dwmy]?$" (name input)) :relative-date | ||
| (re-find #"^[+-]\d+[dwmy]-(ms|start|end|\d{2}|\d{4}|\d{6}|\d{9})?$" (name input)) :relative-date-time |
There was a problem hiding this comment.
Would it be helpful to give some syntactic consistency to the user e.g. end them all in -ms or prefix these with time e.g. 1d-time-ms? There's no consistent word or characters indicating this is a time value
There was a problem hiding this comment.
Thinking more on this, this doesn't need to block this PR. We can adjust the syntax before release as needed
| :where [?b :block/page ?bp] | ||
| [?bp :block/name ?current-page]]} | ||
| {:current-page-fn nil}))) | ||
| ":current-page input fails gracefully when not present") |
There was a problem hiding this comment.
I found this confusing as it's not failing but rather not resolving the input. I'm happy to tweak this wording later
logseq-cldwalker
left a comment
There was a problem hiding this comment.
@bendyorke Thanks for all the great query :inputs features you've added! 👍 🙌
Looks like there's just a nbb-logseq bump to get the last test passing. I can do that in a bit if you don't get to it
…te-input Enhancement: Add +/- syntax, (w)eek (m)onth (y)ear, and time support to query :inputs
This refactors
db-util/resolve-inputto use a multi method like previously discussed with @logseq-cldwalker. There are several things going on in this refactor:+1d,-7d)+1w-3m+2y):journal/+3d). I also thought this could very easily support:query/+3dand:current/+3d, but I'm realizing as I'm writing this that the only time those are really applicable are on journal pages, and I'm pretty sure:journal/+3dwould suffice in both cases.Let me know if the namespaces are too abstract, I'm open to changing the inputs to something more readable like
+3d-journalor:+3d-journal-dayor+3d-from-journal-day, but none of those read right to me. I'm not sure if namespaces are too confusing, but since the day that the query is relative to is kind of like a context, and the rest should function the same, it seemed fitting.