-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: proper sorting resources by age column (#2182 followup) #2414
fix: proper sorting resources by age column (#2182 followup) #2414
Conversation
789773b
to
fd32f2e
Compare
Don't know why
Could you guys help me? |
@MJ111 I just noticed that on some other PRs. So I think CI is borked currently. |
@MJ111 can you please rebase against master? |
@@ -37,21 +38,22 @@ export class ClusterIssues extends React.Component<Props> { | |||
private sortCallbacks = { | |||
[sortBy.type]: (warning: IWarning) => warning.kind, | |||
[sortBy.object]: (warning: IWarning) => warning.getName(), | |||
[sortBy.age]: (warning: IWarning) => warning.age || "", | |||
[sortBy.age]: (warning: IWarning) => warning.getTimeDiffFromNow(), |
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.
Doesn't feel quite right, getTimeDiffFromNow()
calls Date.now()
, which means that for sorting a different "now" is used each time this is called. Could cause problems? Just use a static timeDiffFromNow
in IWarning
? Or we really just need something that converts the age
string to a number (and done when warnings
is populated)?
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.
So age
is getAge()
which calls getTimeDiffFromNow()
anyway.
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.
Right, but it was not getting called during sorting. And also that means we shouldn't need to use getTimeDiffFromNow()
directly.
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.
Fair good point.
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.
Though we also don't want it use a different "now" when creating it. So probably the best solution would be to have a warning.getTimeDiffFrom(firstLoad)
where this.firstLoad = Date.now()
is called in the componentDidMount
method.
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.
Probably beyond the scope of this PR.
If this PR is in line with what we do elsewhere then it's OK. Though I think it could be changed easily enough so that it is using a pre-calculated timeDiffFromNow
value in the sort callback.
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.
Agreed as out of scope, though it shouldn't change the sorting order (too much).
fd32f2e
to
545dd86
Compare
@Nokel81 sorry for the late response. I rebased the branch. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
sorting resources by age in cluster-issues is broken (previously sorted by iso-string timestamp) Signed-off-by: MinJeong Kim <min7859@gmail.com>
545dd86
to
79659e5
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
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.
Can we do these changes at least?
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
fix lint Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
Hello guys, thank you for the awesome project! I'm actively using lens in production.
I recently encountered this bug and searched #2182 PR was merged but omitted this part.
So, As followup, I added this PR.
If you have question, feel free to comment. Thanks.
Fixes:
sorting resources by age is broken (previously sorted by iso-string timestamp) in cluster-issues
AS-IS
TO-BE