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

[50954] Record progress in multiple units #15450

Merged
merged 35 commits into from
Jun 3, 2024

Conversation

cbliard
Copy link
Member

@cbliard cbliard commented May 2, 2024

@cbliard cbliard marked this pull request as draft May 2, 2024 13:37
See: https://gitlab.com/gitlab-org/ruby/gems/gitlab-chronic-duration

Really nice gem to handle parsing and outputting durations in multiple
units.
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch 2 times, most recently from 431f846 to a5065a4 Compare May 7, 2024 16:04
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from a5065a4 to f844feb Compare May 7, 2024 16:48
@aaron-contreras
Copy link
Contributor

eslint is complaining about the chronic_duration.js file. This is taken from Gitlab's implementation and is meant to be kept inline with their chronic_duration gem. There's no npm package for chronic_duration.js as it's directly part of the gitlab source code. Would vendoring the file prevent eslint from trying to check it or is there a config to exclude this file from eslint. Probably has been done before in the core repo but unsure of how to handle it @oliverguenther

@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 2965574 to 58498c9 Compare May 14, 2024 00:07
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 0d5a14d to dfb5d30 Compare May 14, 2024 14:32
This file is sourced from Gitlab's Rails application and provided as
`.js`. We therefore don't want to enforce eslint rules on it to keep
it prisitine with its upstream source.
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from dfb5d30 to 36b3764 Compare May 14, 2024 14:49
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 36b3764 to 147d6ea Compare May 14, 2024 15:13
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 8885105 to 0be7415 Compare May 14, 2024 20:31
@aaron-contreras
Copy link
Contributor

@cbliard 'eqeqeq' eslint issue addressed more globally in #15560

@aaron-contreras aaron-contreras self-assigned this May 21, 2024
@aaron-contreras aaron-contreras added this to the 14.2.x milestone May 21, 2024
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 682e928 to da19e6e Compare May 22, 2024 01:05
Copy link
Member Author

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

I played a little with it. It responds really well. Good job!
3 things I wonder about, and probably @psatyal can help us on it:

  • what do we do with text longer than the allowed size? Currently it's clipping. Do we extend the default width?
  • what about the precision? When entering 1m, it can't represent it accurately with only 2 decimals. It results to "1m 12s". Not a big deal, but it's kinda surprising to enter "2h 12m" and end up with "2h 12m 0.0000000001s", or enter "2h 13m" and end up with "2h 13m 12.00000000001s". Should we switch from floating points holding nb of hours to integer holding nb of seconds?
  • when omitting the "m", or before entering it, the value is interpreted as hours. It would be better if interpreted as minutes. This is especially visible when entering a value for the first time: with w -> rw, and typing each character one by one, it gives this:
    • work -> remaining work (when 100%)
    • 2 -> 2h
    • 2h -> 2h
    • 2h1 -> 3h (would have been expecting 2h 1m)
    • 2h15 -> 17h (would have been expecting 2h 15m)
    • 2h15m -> 2h 15m

Copy link
Member Author

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

I can't approve nor request changes on this PR because I created it 😅

The multiple units display is really nice, and the way it's used in the popover is smooth and does not get in the way. That's nice!

I have some tiny remarks here and there.

I also have the feeling that the precision is annoying us. For instance:

  • entering "2h 13m" leads to 7980 seconds, converted to 2.216666667 hours, rounded to 2.22 (2 decimals). This value 2.22 is the one being saved in database.
  • When frontend is rendering it, it has 2 ways of rendering it:
    • the modal is rendering it through DurationConverter.output, which for 2.22 will render "2h 13m 12s"
    • the angular part is using a different route: the 2.22 is converted in the representer using datetime_formatter.format_duration_from_hours, so 2.22 is converted to iso duration "PT2H13M12S". This duration is then handled in the timezone service which converts it to hours with Number(moment.duration(durationString).asHours().toFixed(2)) which is 2.22, converted to seconds which gives 7992.000000000001, and then it is converted to chronic duration which gives "2h 13m 12.000000000001s"

So the rounding is always false, and sometimes more false than others. I think the second one can be fixed by avoiding converting iso duration to hours and then to second: by converting iso duration directly to seconds, we could avoid precision loss.

Another thing we could do is to avoid displaying seconds entirely by making the hours to seconds conversion remove them. Something like (hours * 3600 + 15).to_i / 60 * 60. For 2.22 hours, it would give 7980 which converts to "2h 13m". No seconds, no errors.

WDYT?

Comment on lines 67 to 76
<div class="op-toast -warning">
<div class="op-toast--content">
<p>
<%= t("working_days.warning").html_safe %>
</p>
</div>
</div>
Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like this warning should belong to the next section. Currently it looks like it belongs to the wrong one.
Maybe @psatyal can confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right. Played around with it and like it more this way:

Banner position demo

Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts @psatyal ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the commit adfa1bd

in case we agree this is where it should be

Copy link
Member Author

Choose a reason for hiding this comment

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

Seen with Parimal during today's frontend meeting:

  • the text has been slightly reworded
  • the warning is moved on top of the section, so the warning can be read before doing the changes

image

He also asked if it's possible when clicking "Apply changes" to display the warning message about changed days only if there are actually changed days. I'll do another review to specifically ask for this so we can track it more easily.

app/views/layouts/base.html.erb Outdated Show resolved Hide resolved
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from ddafeee to 98b00ab Compare May 24, 2024 16:44
aaron-contreras and others added 2 commits May 24, 2024 11:50
Also:
- reword the warning message slightly to remove the "click apply to
  apply" part.
- remove some html_safe calls that are not needed anymore (especially
  since 2f82d73).
@cbliard cbliard force-pushed the feature/50954-record-progress-in-multiple-units branch from 4ed12ac to 1111687 Compare May 27, 2024 09:49
Copy link
Member Author

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

An additional request from Parimal while discussing this screen during today's frontend meeting

Comment on lines -56 to +88

I18n.t('date.day_names').rotate.zip(WeekDay::DAY_RANGE),
direction: :horizontal %>
I18n.t('date.day_names').rotate.zip(WeekDay::DAY_RANGE),
direction: :horizontal %>
Copy link
Member Author

Choose a reason for hiding this comment

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

When clicking "Apply changes", there is this "Change working days" information dialog that always opens itself to warn about changing working days.

image

Parimal would like it to be displayed only if the working days have been actually changed.

Would it be possible?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll create a bug work package for that one.

Copy link
Member Author

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

I can't approve because I created the PR, but I approve it 👍

@aaron-contreras aaron-contreras merged commit 6992e9c into dev Jun 3, 2024
11 checks passed
@aaron-contreras aaron-contreras deleted the feature/50954-record-progress-in-multiple-units branch June 3, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants