-
Notifications
You must be signed in to change notification settings - Fork 71
Description
In the analytics admin, you can select a range of dates to perform your analytics queries on. The date range picker also includes some common ranges like "last 7 days" or "this month". If I select the last 7 days on 2014-07-21 then I'll end up with a URL like:
/admin/#/stats/users/tz=America%2FDenver&start=2014-07-15&end=2014-07-21&interval=day
However, if I bookmark that URL or share it with other admins, they will always be viewing this 7/15-7/21 time frame. This static view of dates may be desirable in some circumstances, but I think if I've selected the "last 7 days" option, then most of the time I want a URL that will always show the last 7 days, regardless of when I access. This would allow you to bookmark that URL or shared URLs for analytics queries you regularly have to pull (for example, if you have to pull your active users every month).
My general thoughts of how this might work:
- If I select any of the date picker's relative date ranges ("today," "yesterday," "last 7 days," "last 30 days," "this month," or "last month") the URL I'm given should use relative dates so if I visit that URL again, I'm still viewing that date range relative to today.
- If I select "Custom Range" from the date picker and then choose specific dates, then the URL should use static dates so loading that URL will always show the specific dates you picked.
- We should add more relative date ranges for common ranges, like YTD, this fiscal quarter, last fiscal quarter, last fiscal year, and maybe others.
- The URL should support elasticsearch's date math. We should use this format where possible for the relative dates (like "last 30 days"), but some other ranges may require our own custom URL parameters (like if we add fiscal quarter ranges). Basing the feature on this date math feature would allow URL hackers to save their own reports for odd date ranges (eg, I want to always look at the last 3 weeks for some reason), without us necessarily having to them in the UI right now (but it would be nice to figure out a more elegant approach in the UI).
All of this really builds towards being able to save common reports, which has been on the radar for a while: NREL/api-umbrella#16 But perhaps just by making the URLs bookmarkable with relative date ranges, that accomplishes most of that goal.
@shawnjohnson Thanks for the idea to use elasticsearch's date math! I hadn't seen that before, but that seems like it'll definitely make this easier and more flexible to implement. Otherwise, does what I've outlined here seem logical to you? Mainly that the date range picker will always result in relative URLs unless you pick "Custom Range" and explicitly pick dates? And while I think exposing the date math in the URL will give you whatever flexibility you need, I am curious what relative date ranges you commonly run queries for, since I'd like to add those to the date range picker. I commonly have to run reports based on fiscal quarters, so I'll probably be adding those ranges, but if you have other frequent ranges, those would be great to know.