Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide time placeholders in RQL with ability to specify plus and minus "duration" #1854

Closed
thjaeckle opened this issue Jan 2, 2024 · 1 comment · Fixed by #1856
Closed
Assignees
Milestone

Comments

@thjaeckle
Copy link
Member

Currently, there is the time:now placeholder which can be used in RQL queries, e.g. like this:

ge(features/ConnectionStatus/properties/status/readyUntil,time:now)

The currently implemented time placeholders are:

  • time:now
  • time:now_epoch_millis

It would be very useful to be able to also specify a plus and minus offset to "now":

  • e.g. querying all of the things which were modified in the last 1 day
  • e.g. counting all of the things which have a ISO8601 timestamp persisted which is more recent than 2 hours

Syntax idea:
To keep it simple, the existing placeholders could support optionally the following syntax:

<sign> := + | -

<unit> := "ms" | "s" | "m" | "h" | "d"
<dittoDuration> := <integer><unit>

<offset> := <sign><dittoDuration>

time:now<offset>
time:now_epoch_millis<offset>

Where Ditto duration is defined by implementation class DittoDuration.

Examples:

  • time:now-5h - current ISO8601 timestamp minus 5 hours
  • time:now_epoch_millis+2d - current epoch timestamp plus 2 days
  • time:now+30s - current ISO8601 timestamp plus 30 seconds
@thjaeckle
Copy link
Member Author

thjaeckle commented Jan 4, 2024

Additional idea: Rounding up/down to the next full "ms" | "s" | "m" | "h" | "d".

Syntax could be e.g.:

time:now_round-d       # rounding down to today's start of the day
time:now-1d_round-d    # rounding down to yesterday's start of the day
time:now-1d_round-h    # rounding down to yesterday's start of the current hour

time:now_round+m       # rounding up the current time to the next full minute

Or:

time:now_floor_d       # rounding down to today's start of the day
time:now-1d_floor_d    # rounding down to yesterday's start of the day
time:now-1d_floor_h    # rounding down to yesterday's start of the current hour

time:now_ceil_m        # rounding up the current time to the next full minute

Or:

time:now[-d]       # rounding down to today's start of the day
time:now-1d[-d]    # rounding down to yesterday's start of the day
time:now-1d[-h]    # rounding down to yesterday's start of the current hour

time:now[+m]       # rounding up the current time to the next full minute

thjaeckle added a commit that referenced this issue Jan 4, 2024
… now

* and to optionally truncate to a unit (rounding down)

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
@thjaeckle thjaeckle added this to the 3.5.0 milestone Jan 4, 2024
@thjaeckle thjaeckle self-assigned this Jan 4, 2024
thjaeckle added a commit that referenced this issue Jan 4, 2024
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thjaeckle added a commit that referenced this issue Jan 5, 2024
…-placeholders

#1854 enhance time:now* placeholders to calculate plus and minus from now
thfries pushed a commit to thfries/ditto that referenced this issue Jan 13, 2024
…nd minus from now

* and to optionally truncate to a unit (rounding down)

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thfries pushed a commit to thfries/ditto that referenced this issue Jan 13, 2024
…er functionality

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant