-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Enabling yesterday option when 24 hours is selected #90017
[APM] Enabling yesterday option when 24 hours is selected #90017
Conversation
cauemarcondes
commented
Feb 2, 2021
Pinging @elastic/apm-ui (Team:apm) |
return [yesterdayOption, aWeekAgoOption]; | ||
} | ||
|
||
// Less than one week | ||
if (dateDiff <= 7) { | ||
if (dateDiffInHours <= weekDurationInHours) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test for this component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'm still wondering why the test doesn't need updating when the implementation changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few more tests, also to cover what was discussed in the comments below.
@@ -23,6 +23,8 @@ const PrependContainer = styled.div` | |||
padding: 0 ${px(unit)}; | |||
`; | |||
|
|||
const weekDurationInHours = moment.duration(7, 'days').asHours(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: There's always the vanilla option. Might also be the simplest to read:
const weekDurationInHours = moment.duration(7, 'days').asHours(); | |
const weekDurationInHours = 24 * 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should consider using moment here, but scoped to the current time, to deal with issues like DST. E.g.:
const aDayAgo = momentEnd.subtract(1, 'days').getTime();
const isAtLeastADayAgo = momentStart.getTime() <= aDayAgo;
const aWeekAgo = momentEnd.subtract(1, 'week').getTime();
const isAtLeastAWeekAgo = momentStart.getTime() <= aWeekAgo;
(we should figure out how exactly moment.subtract() deals with DST ofc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit I'm not quite sure why we are using hours here, are we rounding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, should this not be "a day before" and "a week before" (the current time range), rather than yesterday/a week ago?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, should this not be "a day before" and "a week before" (the current time range), rather than yesterday/a week ago?
Good point. The current copy is only applicable if the end range is now.
I think we could keep the labels if we add a check like:
const = end === Date.now();
if (dateDiffInHours <= 24 && isEndNow) {
We might have to add some padding like:
const isEndNow = end + 1000 >= Date.now();
if (dateDiffInHours <= 24 && isEndNow) {
return [yesterdayOption, aWeekAgoOption];
}
If isEndNow
is false we'll fall back to prevPeriodOption
which might be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, should this not be "a day before" and "a week before" (the current time range), rather than yesterday/a week ago?
Good catch! And I agree, the more clear we can be with the relative time the easier it is to parse for the user. So if we can add a check as @sqren proposes, I'm very happy 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End is rounded.
That's why I thought we could add padding. But since rounding is up to 5 minutes we'd need a lot of padding so I agree, not a great solution.
But maybe we can use the query parameter? E.g. if rangeTo=='now'
Much better idea. Let's try to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit I'm not quite sure why we are using hours here, are we rounding?
@dgieselaar I switched to use hours
because when I used days
and the difference between the dates is for example 25 hours
the days difference still returns 1
. But I only want to show the yesterday
option when the difference is less or equal to 24 hours.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can pass a third argument, a boolean, to diff to get a floating point number instead of an integer. then you could just use <= 1. https://jsfiddle.net/8whg49qj/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks will do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from a UX design 👁️
@formgeist I added the time when showing the previous period, I think it'll help the user to understand what is the exact time that is being compared. Let me know if you don't want to keep it. |
No, this is good 👍 |
@elasticmachine merge upstream |
When comparison is enabled but there is only one option we show that option as disabled. It looks to me like the compared date ( In contrast: when comparison actually is disabled we don't disable the selector. Why is this? Looks to me like we compare with Yesterday. Suggestion |
Will disable the select box too.
This was a discussion a had with @formgeist a few days ago, the problem is that select input doesn't have a But in the end, @formgeist and I agreed that we could go like this (disabling the select) for now, and we could change to a label or maybe a text input with read-only property later if needed. |
What about just leaving it as non disabled until we have a read-only property? Afaik we don't disable other dropdowns when there's only one option, do we? Eg. transaction type selector or agent config. |
Btw. I don't think read-only is the right approach either tbh. A drop-down is always read only (in contrast to an input field). If we want to make it clear that there's only a single option we shouldn't use a dropdown but a label. But I'm not sure it's critical to indicate this, is it? |
That works for me too. |
Sounds good to me too 👍 |
826595e
to
b3362b4
Compare
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
* master: (244 commits) [maps] Top hits per entity--change to title to use recent, minor edits (elastic#89254) [DOCS] Update installation details (elastic#90354) RFC for automatically generated typescript API documentation for every plugins public services, types, and functionality (elastic#86704) Elastic Maps Server config is `host` not `hostname` (elastic#90234) Use doc link services in index pattern management (elastic#89937) [Fleet] Managed Agent Policy (elastic#88688) [Workplace Search] Fix Source Settings bug (elastic#90242) [Enterprise Search] Refactor MockRouter test helper to not store payload (elastic#90206) Use doc link service in more Stack Monitoring pages (elastic#89050) [App Search] Relevance Tuning logic - actions and selectors only, no listeners (elastic#89313) Remove UI filters from UI (elastic#89793) Use newfeed.service config for all newsfeeds (elastic#90252) skip flaky suite (elastic#85086) Add readme to geo containment alert covering test alert setup (elastic#89625) [APM] Enabling yesterday option when 24 hours is selected (elastic#90017) Test user for maps tests under import geoJSON tests (elastic#86015) [Lens] Hide column in table (elastic#88680) [Security Solution][Detections] Reduce detection engine reliance on _source (elastic#89371) [Discover] Minor cleanup (elastic#90260) [Search Session][Management] Rename "cancel" button and delete "Reload" button (elastic#90015) ...