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

Made Last Seen more human readable #9112

Merged
merged 1 commit into from Nov 22, 2015
Merged

Made Last Seen more human readable #9112

merged 1 commit into from Nov 22, 2015

Conversation

ritvikgautam
Copy link
Contributor

I've updated the last seen format as per #8956

@mattab mattab added the Needs Review PRs that need a code review label Oct 29, 2015
@mattab mattab added this to the 2.15.1 milestone Oct 29, 2015
$seconds = floor($reminder - $minutes * 60);
$time = sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
$time = sprintf("%02s", $days) . ':' . sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
$centiSeconds = ($numberOfSeconds * 100) % 100;
if ($centiSeconds) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we maybe display days only if there was actually a day? Also it formats a time here, I'm not sure if eg 01:01:01:01 would be clear that the first one is actually meant as days? Not sure how one would format something like this. Maybe we'd need to generate full date in this case? eg something like 2015-01-01 01:01:01?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please have a look at the latest commit.
I've tried to make it something like "5 days, 05:03:01", and the days part is only visible when days > 0.

@ritvikgautam
Copy link
Contributor Author

@tsteur Please have a look at the updated version!

if($days == 0)
$time = sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
else
$time = sprintf("%02s days, ", $days) . sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
Copy link
Member

Choose a reason for hiding this comment

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

"days" needs to be translated. You can see it a few lines further below how it works. You want to use the translation key Intl_NDays. Eg like Piwik::translate('Intl_NDays', $days)

Copy link
Member

Choose a reason for hiding this comment

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

In the test I just noticed it says 01 days, 10:00:00 I think 1 days instead of 01 days would be better here. Ideally it would say 1 day and 3 days but we don't have to take care of this now as we always use plural so far everywhere

@tsteur
Copy link
Member

tsteur commented Nov 4, 2015

Are you familiar with unit tests? It would be good to have this code covered by tests. Existing tests are located in tests/PHPUnit/Unit/Metrics/FormatterTest.php and you can add a test case to getPrettyTimeFromSecondsData() method (there is already a test case that needs to be fixed as the test is failing see https://travis-ci.org/piwik/piwik/jobs/89089715 ). To run these tests execute ./console tests:run unit

@ritvikgautam
Copy link
Contributor Author

@tsteur I've made the changes as per your comments, please have a look!
Thank you so much, I'm getting to learn so much here! :)

I'm not really familiar with the tests (I'm new) but I'll have a look and try to understand.
Thanks!

@ritvikgautam
Copy link
Contributor Author

@tsteur As per my understanding, the tests are failing because they are still expecting the older values.
I'm not really sure where those expected values are stored.

@ritvikgautam
Copy link
Contributor Author

@tsteur I've updated the expected values in the test file. :)

@ritvikgautam
Copy link
Contributor Author

@tsteur There are still some fails caused due to my edit in the test file. I'm not sure how to go about this.
https://travis-ci.org/piwik/piwik/builds/89796774

if ($days == 0) {
$time = sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
}
else {
Copy link
Member

Choose a reason for hiding this comment

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

Just for the next time: In our coding style we usually use } else { in one line but it's alright for now :)

@tsteur
Copy link
Member

tsteur commented Nov 8, 2015

The failing tests are not related to your change. All good :)

@ritvikgautam
Copy link
Contributor Author

@tsteur Thank you so much for your continuous guidance! :)
I've updated the code with the proper } else { style :)

@mattab
Copy link
Member

mattab commented Nov 9, 2015

Hi @ritvikgautam thanks for PR! maybe you could also squash your commits into one bigger commit? http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit

@tsteur
Copy link
Member

tsteur commented Nov 9, 2015

@ritvikgautam If you're familiar with squashing commits it would be good to give it a try (see blog post) otherwise let us know

@ritvikgautam
Copy link
Contributor Author

@mattab @tsteur I'm new so I'm confused here on how to go about it. :-/

@tsteur
Copy link
Member

tsteur commented Nov 17, 2015

I was just waiting for an answer re the squashing of commits ( http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit ) then I will merge. Are you familiar with squashing commits or can you give it a try maybe? What happens there is that you squash those 5 commits into one commit via in your case something like git rebase -i a3d394eb969dca2896c4bb31440444cb88c1f69c

@ritvikgautam
Copy link
Contributor Author

@tsteur It's all a little bit confusing for me. Will it be okay if I just create a new pull request?

@tsteur
Copy link
Member

tsteur commented Nov 18, 2015

Sure that's fine as well @ritvikgautam

Update Formatter.php

Update Formatter.php

Made changes in the coding style, added translation for 'days'.

Update FormatterTest.php

Made some changes in the expected array.

Update Formatter.php

Code style.

Made the last seen time more human readable by incorporating days in the time format.
@ritvikgautam
Copy link
Contributor Author

@tsteur @mattab I've squashed all the changes in one commit! :D

@tsteur
Copy link
Member

tsteur commented Nov 22, 2015

Awesome, thx for that :)

tsteur added a commit that referenced this pull request Nov 22, 2015
Made Last Seen more human readable
@tsteur tsteur merged commit 0d3ea49 into matomo-org:master Nov 22, 2015
@mattab mattab added the Regression Indicates a feature used to work in a certain way but it no longer does even though it should. label Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants