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

occ: Improve user:lastseen timestamp #44666

Merged
merged 6 commits into from
Aug 7, 2024
Merged

Conversation

nooblag
Copy link
Contributor

@nooblag nooblag commented Apr 4, 2024

Summary

TODO

  • Decide whether to display times always in UTC or pull Timezone from php.ini setting
  • Fix bug in user:info where last login is zero (don't show Unix epoch time)

Checklist

@nooblag
Copy link
Contributor Author

nooblag commented Apr 7, 2024

Hello all @nickvergessen @skjnldsv @ArtificialOwl @Fenn-CS @come-nc -- I understand you've got a lot going on, but just a friendly question to see if the timetable for this might make it in before NC29 final at the end of this month, by any chance? If so, I'll get working on the documentation changes too, etc?

@Fenn-CS
Copy link
Contributor

Fenn-CS commented Apr 7, 2024

but just a friendly question to see if the timetable for this might make it in before NC29 final at the end of this month, by any chance? If so, I'll get working on the documentation changes too, etc?

The next RC release for Nextcloud 29 is on May 30th, not sure if that answers your question but I believe as soon as this is ready and is reviews it would definitely get into the next release if back-ported to NC29 as master is now NC30.

@nooblag
Copy link
Contributor Author

nooblag commented Apr 7, 2024

Hi @Fenn-CS Thanks for all that, it's helpful information. This is ready for review now.

if ($user->getLastLogin() == 0) {
$lastseen = "never";
} else {
$lastseen = date('Y-m-d H:i:s T', $user->getLastLogin());
Copy link
Member

Choose a reason for hiding this comment

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

Both, the format change as well as the timezone change are breaking behaviour of the command that will result in breaking all tools/scripts that utilize those commands.

My recommendation would be to add an optional --timezone argument and use the given timezone when provided and leave any calls without it untouched.

Copy link
Contributor Author

@nooblag nooblag Apr 8, 2024

Choose a reason for hiding this comment

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

Thank you for the input. I understand it's a breaking change. The point of this PR is to unify the timestamps though, and since 29.0.0 by way of semantic versioning denotes breaking changes in the API, breaking changes are acceptable, no?

At the moment we have different formatting at user:info and user:lastseen anyway, so unifying them (along with the bug fixing too) will be breaking changes in either case.

Copy link
Member

Choose a reason for hiding this comment

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

While we try to follow semantic versioning, breaking should be avoided as much as possible, that includes changing defaults and things like this here.
A newly added optional parameter can be used to fix your case without breaking existing usages.

Copy link
Contributor Author

@nooblag nooblag Apr 8, 2024

Choose a reason for hiding this comment

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

Thank you for the note.

I am saying there will be a breaking change regardless though. Putting the formatting aside, fixing the bug when last seen time = 0 by saying "never" instead of returning Unix epoch will be a breaking change. And so if we're fixing an issue that will result in a breaking change anyway, why not unify the timestamp formatting while we're at it? Unless there's a reason that unifying the formatting change here is specifically undesirable?

Is the existing DateTimeInterface::ATOM format consistent and the established default in occ in other areas?

For background, and FWIW, the changes merged in #39669 changed the timestamp formatting in user:lastseen from d.m.Y H:i to Y-m-d H:i without any controversy, and that's technically a breaking change for scripts.

I'm not trying to be difficult, just trying to understand the hesitancy.

Copy link
Member

Choose a reason for hiding this comment

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

just trying to understand the rationale.

I missed it in the other PR.

Copy link
Contributor Author

@nooblag nooblag Apr 8, 2024

Choose a reason for hiding this comment

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

Well, you'll also note there then that @come-nc wanted to do some other cool stuff like a complete overhaul of the timestamp line to show the date first to allow better sorting (which would also be good)... But anyways.

I'd obviously like to see some changes here to have consistency, which is the whole point of this discussion, but if that stalemates, I'll retract. I'd rather not introduce a --timezone argument that only applies to user:info and not user:lastseen -- my whole point here is looking for some consistency across occ, which at the moment, we don't have (along with the bug fix).

Copy link
Contributor

Choose a reason for hiding this comment

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

But the timezone used is consistent accross occ, no? Only the date format is not always the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. 👍

@come-nc come-nc added this to the Nextcloud 30 milestone Apr 8, 2024
core/Command/User/Info.php Outdated Show resolved Hide resolved
@nooblag
Copy link
Contributor Author

nooblag commented Apr 27, 2024

Hi all, so just wondering how to move forward with this, given it's been a few weeks since our discussion where we've landed on the decision around keeping everything in UTC. Just wondering about the other parts:

  • Is the bug fix for user:info lastseen=0 okay?
  • Seems there's strong desire to keep the time and date format for user:info as ATOM. How about for user:lastseen though? Change that to ATOM too? Or leave it and just improve the "prettiness" (i.e. adding seconds and timezone)?

Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

@nooblag
Copy link
Contributor Author

nooblag commented May 17, 2024

Just a friendly follow up on #44666 (comment)

@come-nc
Copy link
Contributor

come-nc commented May 21, 2024

Hi all, so just wondering how to move forward with this, given it's been a few weeks since our discussion where we've landed on the decision around keeping everything in UTC. Just wondering about the other parts:

  • Is the bug fix for user:info lastseen=0 okay?

Well, it’s complicated. I agree it would be better to show "never" rather than epoch, but changing that will break scripts relying on the output of the command.

  • Seems there's strong desire to keep the time and date format for user:info as ATOM. How about for user:lastseen though? Change that to ATOM too? Or leave it and just improve the "prettiness" (i.e. adding seconds and timezone)?

I have no strong opinion about adding seconds and timezone to user:lastseen.
Do you have before/after screenshots?

@nooblag
Copy link
Contributor Author

nooblag commented May 21, 2024

Thanks for getting back.

Well, it’s complicated. I agree it would be better to show "never" rather than epoch, but changing that will break scripts relying on the output of the command.

I appreciate and understand that. If we don't want to break things, then we can just leave it as it is. Or, as I've said above, I'm open to suggestions on how to make changes in the least disruptive/most useful way.

PS what are some examples of all these scripts that are being referred to? And how is the importance of such 3rd party products considered against/above making changes to Nextcloud core?

I have no strong opinion about adding seconds and timezone to user:lastseen. Do you have before/after screenshots?

I would prefer to introduce seconds to user:lastseen along with the timezone to make it explicit to the user that the returned values are hardcoded UTC, and not local settings (I've been confused by this in the past, without the timezone information, thinking these times were local times). Sure, here are some screenshots.

Before PR:

Screenshot from 2024-05-21 21-12-52

Current PR:

Screenshot from 2024-05-21 21-12-23

@nooblag
Copy link
Contributor Author

nooblag commented Jul 1, 2024

Hi all, just another friendly ping on #44666 (comment).

@nooblag
Copy link
Contributor Author

nooblag commented Jul 23, 2024

Hi all, just another friendly ping on #44666 (comment), please?

@come-nc
Copy link
Contributor

come-nc commented Aug 1, 2024

Thanks for getting back.

Well, it’s complicated. I agree it would be better to show "never" rather than epoch, but changing that will break scripts relying on the output of the command.

I appreciate and understand that. If we don't want to break things, then we can just leave it as it is. Or, as I've said above, I'm open to suggestions on how to make changes in the least disruptive/most useful way.

PS what are some examples of all these scripts that are being referred to? And how is the importance of such 3rd party products considered against/above making changes to Nextcloud core?

I do not have a good answer for that. I do not have an example of a script, it’s just that there may be some out there and we should not break compatibility without a good reason.
Whether showing never instead of epoch is a good enough reason is hard to arbitrate. I’d say it should not be changed in the json output of the command.
Regarding the default output, yeah it’s nicer to see never but it’s not that bad to see epoch, no one has Nextcloud servers running since 1970 so it’s quite easy to understand that this means never.

I have no strong opinion about adding seconds and timezone to user:lastseen. Do you have before/after screenshots?

I would prefer to introduce seconds to user:lastseen along with the timezone to make it explicit to the user that the returned values are hardcoded UTC, and not local settings (I've been confused by this in the past, without the timezone information, thinking these times were local times). Sure, here are some screenshots.

Before PR:

Screenshot from 2024-05-21 21-12-52

Current PR:

Screenshot from 2024-05-21 21-12-23

That part looks nicer indeed and I’d be fine with merging that.

@nooblag
Copy link
Contributor Author

nooblag commented Aug 2, 2024

Thanks for responding.

Great, if we agree on the --lastseen changes, let's please merge them for NC 30?

And as I say, I won't keep pushing on the other, apart to still note in a friendly way, that it remains a bit confusing/dubious the reluctance over the tiniest breaking change for 3rd party scripts that are both uncited and still being considered above the level of core development...

Again, I'm no longer pushing, we can compromise here, and I'll remove it from the PR, but I do want to say that I think returning epoch date is not only incorrect data (even if no NC servers have been running since 1970), it remains my view that it's a bug, and it should say 'never', which is the correct data. But I've said all this already many times ;)

Anyway, will add a commit to reflect these discussions, and just accept the --lastseen change.

Thanks!

@Altahrim Altahrim mentioned this pull request Aug 5, 2024
@come-nc come-nc added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Aug 5, 2024
@come-nc
Copy link
Contributor

come-nc commented Aug 5, 2024

CI failures unrelated, good for merging

Copy link
Member

@AndyScherzinger AndyScherzinger left a comment

Choose a reason for hiding this comment

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

🐘

Signed-off-by: Jore <contact@jore.cc>
Signed-off-by: Jore <contact@jore.cc>
Signed-off-by: Jore <contact@jore.cc>
Signed-off-by: Jore <contact@jore.cc>
Signed-off-by: Jore <contact@jore.cc>
Signed-off-by: Jore <contact@jore.cc>
@skjnldsv skjnldsv merged commit 80fc2a9 into nextcloud:master Aug 7, 2024
3 of 4 checks passed
@Altahrim Altahrim mentioned this pull request Aug 7, 2024
@nooblag nooblag changed the title occ: Improve and make consistent user:lastseen and user:info timestamps occ: Improve user:lastseen timestamp Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

occ: Improve user:lastseen timestamp
7 participants