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

Rely purely on moment to determine input validity #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brockpetrie
Copy link
Owner

@brockpetrie brockpetrie commented Jul 17, 2018

Removes our falsey check on input on line 38. This allows for undefined inputs, which are considered valid by moment and treated the same as calling new Date().

This also removes the console warning in that same if block.

Fixes #75, closes #81 and closes #91. Breaking change! Any thoughts on this, @BrockReece?

Thanks to @bitencode for doing the initial legwork.

@BrockReece
Copy link
Collaborator

The code changes make sense, the only thing is that this contradicts the changes we made for #29

@brockpetrie
Copy link
Owner Author

That is a pretty big contradiction, isn't it... How do you feel about it? I think I've come full circle: respect how Moment handles inputs, and either proceed or abort depending on Moment's thumbs up.

Copy link
Collaborator

@BrockReece BrockReece left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong feelings either way to be honest, though a lot of feedback we had in the issues was around not firing the console warning rather than displaying nothing if the input is falsey.

@bitencode
Copy link

@brockpetrie - I've been testing this branch with our system and it works well. I agree with your assessment that undefined should be a valid input and run the filter as if the time were "now". In our app we don't use (or pass to moment) undefined times, but I think that's a good option. We do use null a lot as timestamps when an event has not occurred (which is where we were getting all the console warnings).

For instance, this snippet of markup:

    td.no-data-dash {{ item.instanceType }}
    td.no-data-dash {{ item.version }}
    td.no-data-dash {{ item.startedAt | moment() }}
    td.no-data-dash {{ item.stoppedAt | moment() }}

Helps to produce the following:
dev___providers

Everywhere there are dashes in the UI is where there was null data - in this case no "Last Launched" or "Last Stopped" dates. The page that's clipped from actually has dozens of the main rows with expandable details I'm showing here. Results are potentially multiple hundreds of detail rows, many which may have null timestamps for specific events. We use this same pattern though-out our application, so not having the console warnings is very nice 😉

It also means that it's important to have no output if the input is null (which this PR keeps) so that the .no-data-dash CSS class can do its thing if the td is empty.

There are situations where we end up rendering a lot of data that has had few or no events yet - ex:
dev___providers

That brings me to the only suggestion I have for this PR. In #81 at the top of the function I had a null guard (it also guarded undefined (which we don't actually want). But, I noticed when I was timing the page renders that for a page with many null time values (which we have a lot of) that short-circuit speeds up that page. It's up to you, but adding if (input === null) return; at the top apparently avoids a lot of unnecessary processing.

Either way, we'd very much like to have this be the default behavior, so you get my 👍 for merging 😄

@bitencode
Copy link

Though I was just re-reading your comments from 3 days ago about my PR #81 going too far by guarding the invalid inputs... so yeah - either way, letting moment do the processing means you'll get whatever it does at a small performance penalty for "invalid" inputs (null, empty string). Guarding those values at the top will give you a performance bump, but I'm not clear on how much and it's possible our status pages that contain a lot of as-yet pending events are unusual.

I'm also happy to close #81, but it looks like when you merge this it will automatically close, so leaving it for now.

Thanks!

@bitencode
Copy link

Have you thought about merging this at all? We are still using our modified fork. Someday I'd like to switch back to your npm package instead.

Thanks!

@kamerat
Copy link

kamerat commented Dec 20, 2018

Leaving this PR hanging like this is torture. So close, yet so far.. ☹️

@cManfredi
Copy link

Any updates about this PR?

Copy link
Collaborator

@BrockReece BrockReece left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just bite the bullet and go with this.

@BrockReece
Copy link
Collaborator

@brockpetrie Are you happy for me to merge this in and release?

@bitencode
Copy link

Yes! One of the Brocks please merge this 😁 (coming up on one year since I did the first pull request for this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support empty values without warning
5 participants