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

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from

Conversation

cbliard
Copy link
Member

@cbliard cbliard commented May 2, 2024

@cbliard cbliard marked this pull request as draft May 2, 2024 13:37
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 2, 2024 13:38 Inactive
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 from 0dd81ea to 431f846 Compare May 7, 2024 14:23
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 7, 2024 14:24 Inactive
@aaron-contreras aaron-contreras force-pushed the feature/50954-record-progress-in-multiple-units branch from 431f846 to a5065a4 Compare May 7, 2024 16:04
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 7, 2024 16:04 Inactive
@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
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 7, 2024 16:49 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 8, 2024 20:31 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 9, 2024 15:13 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 9, 2024 15:24 Inactive
@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

@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 13, 2024 23:14 Inactive
@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
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 14, 2024 00:08 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 14, 2024 12:37 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 14, 2024 14:16 Inactive
@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
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 21, 2024 19:11 Inactive
@aaron-contreras aaron-contreras self-assigned this May 21, 2024
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 21, 2024 20:45 Inactive
@aaron-contreras aaron-contreras added this to the 14.2.x milestone May 21, 2024
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 22, 2024 01:03 Inactive
@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
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 22, 2024 01:15 Inactive
@aaron-contreras aaron-contreras marked this pull request as ready for review May 22, 2024 01:53
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 22, 2024 01:53 Inactive
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 34 to 38
validate :hours_per_day_are_present
validate :days_per_week_are_present
validate :days_per_month_are_present
validate :days_per_week_and_days_per_month_are_consistent
Copy link
Member Author

Choose a reason for hiding this comment

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

It does not validate enough IMHO:

  • It should not be possible to set 24h per day, 7 days per week, or 31 days per month. It should raise an error
  • It should not be possible to enter negative values
  • It should not be possible to enter zero values or text. Using text is "blocked" client side, but not checked server side. When doing so with a curl request, the value is interpreted as 0 due to some to_i or to_f here and there.
    • When hours per day value is 0, it leads to division by zero errors when converting time

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

app/views/layouts/base.html.erb Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 24, 2024 15:21 Inactive
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 24, 2024 16:33 Inactive
@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
@github-actions github-actions bot temporarily deployed to gh-6899875-pr-15450 May 24, 2024 16:45 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants