rilldata / rill

Rill is a tool for effortlessly transforming data sets into powerful, opinionated dashboards using SQL. BI-as-code.
https://www.rilldata.com
Apache License 2.0
1.65k stars 111 forks source link

Last x weeks show time range in the future #5061

Open amir20 opened 3 months ago

amir20 commented 3 months ago

Describe the bug When choosing last 4 weeks, the time range is partially in the future. For example, today is June 11th, but last 4 weeks is shown as May 20 - June 17th which obviously doesn't exist.

To Reproduce Steps to reproduce the behavior:

  1. Go to time drop down for time range
  2. Choose any of the Last X period. The bigger the range the more obvious
  3. Notice that part of the range is in the future.

Expected behavior It seems like the logic is using fixed time window instead of last trailing window.

Screenshots

Screenshot 2024-06-11 at 9 52 34 AM

Desktop (please complete the following information):

Additional context I did a quick search and didn't find any other similar issues.

mindspank commented 3 months ago

@amir20 Do you have any data points that are in the future? We calculate the end of the period as your max timestamp currently

amir20 commented 3 months ago

I don't think I do. I was curious so started switching between different dates. It is weird that the time range jumps between last day, week, 14 days and 4 weeks. I think if you said is true, then I would expect the ending time to always be consistent.

Here is a video recording to show what I mean. If you see, the end time keeps changing. Even more crazy last 6 hours is June 21st. Which is not true for today on June 26th.

https://github.com/rilldata/rill/assets/260667/3bb22534-0556-4b07-8c1b-39ba317799d3

Let me know if you want me to share my dashboard.

mindspank commented 3 months ago

Ah gotcha! Thanks for sharing. Yeah... this is an area we are actively working on right now as the display is slightly confusing. Right now our start ranges are "inclusive" and end ranges "exclusive", so Last 24h would show for example 1 Jan 00:00 - 2 Jan 00:00 which is slightly confusing. Same with the Last X Week as we snap to the end of that week (Monday 00:00).

In your case it also looks like you are running into a double whammy as you also have timezone offset from UTC which makes it even more confusing.

We are currently working on a new time range control in this PR: https://github.com/rilldata/rill/pull/4422 I verified that the 1 day / Last 24h looks correct and as you would expect in that PR, let me also check how Last X Weeks behaves.

medriscoll commented 3 months ago

@amir20 As @mindspank mentioned, we're making changes to rationalize the labeling of these time ranges.

You are seeing two separate issues:

1) Confusing labeling of time range end points: Formally most software frameworks define time ranges as semi-closed intervals [start, end) where the range is exclusive of the ending time. So a time range of "10-11am" excludes 11:00am. However, for day or above granularity, human conventions are that "June 10-11" to include June 11.

2) Confusing labeling of time ranges with incomplete periods: Rill defines "Last 4 weeks" as a range encompassing four week starts (e.g. three Sundays ago through this coming Sunday). If the current day is Wednesday, we were labeling that range as ending on a future Sunday. (This is similar to defining "Current month" as "June 1-31" even if the current date is June 26).

These coming updates will resolve these UX irregularities you're witnessing.

amir20 commented 3 months ago

So my initial intuition on week ending with fixed periods was right.

Isn't it confusing for last 4 weeks to have time in the future? I can't imagine the user ever wanting a period that doesn't exist.

I have worked on a lot of dashboards and can't recall every having last 4 weeks show data that doesn't exist yet.

Even if the labeling was changed to Current month I would expect to only show data upto today.

medriscoll commented 3 months ago

@amir20 We agree with you which is why we're updating the labeling behavior to accord with your expectations. :)

jaroet commented 2 months ago

Even if the labeling was changed to Current month I would expect to only show data upto today.

For me the above statement would not be correct. For 'Current month' I would expect to see all data for the month of now(). There are scenarios (like shipping dates that can be in the future using a planning tool) where there is data in the future. I would want to see that data included in 'Current month'.

I think @amir20 would want to see a 'Current month to date' that would show all data of the current month up to the today.

mindspank commented 2 months ago

@jaroet Agree, we'd want to support basically "This Month" (2024-07-01 - 2024-07-31) and "This Month so far" (2024-07-01 to now).

We are thinking of supporting that via borrowing the time range syntax from Grafana and extend it to also be able to define the comparison range so that you can get even comparison buckets so that "This Month so far" would compare to "same time range last month"

amir20 commented 1 month ago

I saw some small improvements in the UI 🚀

Screenshot 2024-08-10 at 9 19 03 AM

Selecting previous X weeks still seems confusing though. But I have noticed little improvements. For example, today (Aug 10th) still selects up to tomorrow which doesn't exist.

I am not sure if this issue is being worked on actively.