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

[#57529] Add options for sum totals calculation mode in hierarchies #16649

Merged

Conversation

aaron-contreras
Copy link
Contributor

@aaron-contreras aaron-contreras commented Sep 6, 2024

Ticket

https://community.openproject.org/work_packages/57529

What are you trying to accomplish?

Adding a new setting in order to allow users to determine the way in which they'd like sum totals of percent complete in work package hierarchies to be calculated.

  1. Simple average (default): Work is ignored and the total % Complete will be a simple average of % Complete values of work packages in the hierarchy.
  2. Weighted by work: The total % Complete will be weighted against the Work of each work package in the hierarchy. Work packages without Work will be ignored.

Screenshots

Not yet

What approach did you choose and why?

  1. Extend the UpdateAncestorsService to calculate the total % complete based on the current Setting value.
  2. Add a radio group entry to the progress tracking settings page to be able to toggle between the modes.
  3. Add a job that recalculates all total % complete values that gets triggered when the mode is changed in the settings page.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@aaron-contreras aaron-contreras self-assigned this Sep 6, 2024
@aaron-contreras aaron-contreras added this to the 14.6.x milestone Sep 6, 2024
@aaron-contreras aaron-contreras force-pushed the implementation/57529-options-for-total-calculation-sum-mode branch 5 times, most recently from 329b1ac to a630784 Compare September 12, 2024 17:39
@aaron-contreras aaron-contreras force-pushed the implementation/57529-options-for-total-calculation-sum-mode branch 5 times, most recently from 677ecbb to dfddcbb Compare September 20, 2024 16:43
@aaron-contreras aaron-contreras force-pushed the implementation/57529-options-for-total-calculation-sum-mode branch from 0bd1e6d to bc12c60 Compare September 23, 2024 22:54
* Adds the settings to the definitions file.

* Sets the default and allowed values.
* Adds setting into derivation code.

* Adds specs for the simple average mode calculation.
Now the settings can be changed from the UI.
* Fixes cuprite flag to enable cuprite in this spec file.
Calculation of % Complete hierarchy totals should be the second
setting on the form
* Triggers job
* Adds journal entries with specs and translations
@aaron-contreras aaron-contreras force-pushed the implementation/57529-options-for-total-calculation-sum-mode branch 2 times, most recently from 36ae30b to 27e5d87 Compare September 24, 2024 18:39
* Adds temporary depth table - Could be cleaned up down thie line with
  the `work_package_hierarchies` table.
@aaron-contreras aaron-contreras force-pushed the implementation/57529-options-for-total-calculation-sum-mode branch from 27e5d87 to 1f12393 Compare September 24, 2024 21:56
Copy link
Member

@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.

Nice work so far 👏

I only looked at code so far. I need to play a bit with it now.

spec/features/admin/progress_tracking_spec.rb Outdated Show resolved Hide resolved
app/services/settings/update_service.rb Outdated Show resolved Hide resolved
In `WorkPackages::UpdateAncestors::Loader`, the returned elements are
not always `WorkPackageLikeStruct` instances: whenever possible the
loader reuses knows instances of `WorkPackage` when looking for
ancestors or descendants.
In this case, there is no calculated simple average: the ∑ % Complete
should be cleared.
I'm not sure why it fails now while it did not before. Maybe it's when
switching to cuprite. Anyway this test is not worth enough to bother
fixing it.
Just to be extra-sure this case is handled correctly in jobs as well.
@cbliard cbliard self-assigned this Sep 25, 2024
Copy link
Member

@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.

Well done. I think it's good to go now.

@@ -188,7 +188,6 @@ def update_totals
if Setting.total_percent_complete_mode == "work_weighted_average"
update_total_percent_complete_in_work_weighted_average_mode
elsif Setting.total_percent_complete_mode == "simple_average"
update_total_percent_complete_in_work_weighted_average_mode
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@cbliard cbliard marked this pull request as ready for review September 26, 2024 06:10
@cbliard cbliard merged commit d86dfdc into dev Sep 26, 2024
12 checks passed
@cbliard cbliard deleted the implementation/57529-options-for-total-calculation-sum-mode branch September 26, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants