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

Update: Group samples count calculation should include shared groups and projects #862

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

malchua
Copy link
Contributor

@malchua malchua commented Dec 6, 2024

What does this PR do and why?

Describe in detail what your merge request does and why.
This PR changes the sample count of a group to incorporate sample counts from it's shared groups and projects. This update will allow the samples count to properly reflect the amount of samples shown after clicking samples on the sidebar for a group.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.
General check:

  1. Click on Groups in the sidebar.
  2. Take note of the samples count for any group that you know has a group or project shared with it. Click on that group.
  3. Click on Samples in the sidebar.
  4. At the bottom of the page, there is a section saying "Display 1-20 of X items" where X is the total number of samples this group has access to. Confirm that this number equals the one noted in step 2.

Sharing a project:

  1. Click on Groups in the sidebar.
  2. Take note of the samples count for any group that you have access to.
  3. Click on Projects in the sidebar.
  4. Select a project that you own, that has not already been shared to the group in step 2.
  5. Click on Members in the sidebar.
  6. Select the "Invite group" button.
  7. Select the group that was noted in step 2, and give it an access level of Analyst. Click "Share".
  8. Repeat the general check above with the group selected in step 2. The samples count should have increase by the direct samples count** of the project we shared.

Sharing a group:

  1. Click on Groups in the sidebar.
  2. Take note of the samples count for any group that you have access to.
  3. Select a different group that you have access to and want to share with the group in step 2. This different group should not already be shared with the group in step 2.
  4. Click on Members in the sidebar.
  5. Select the "Invite group" button.
  6. Select the group that was noted in step 2, and give it an access level of Analyst. Click "Share".
  7. Repeat the general check above with the group selected in step 2. The samples count should have increase by the direct samples count** of the group we shared.

**Direct samples count for a shared project = samples count of that project
**Direct samples count for a shared group = the sum of all samples found within projects in itself and it's ancestor groups. (This does not include the samples count of projects or groups that have been shared with it)

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@malchua malchua force-pushed the group/total-samples branch from 201b69c to b597634 Compare December 18, 2024 19:09

This comment has been minimized.

@malchua malchua marked this pull request as ready for review December 18, 2024 19:50
@malchua malchua added the ready for review Pull request is ready for review label Dec 18, 2024
Copy link
Member

@JeffreyThiessen JeffreyThiessen left a comment

Choose a reason for hiding this comment

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

Looks good and is working as specified. Just one small change.

@@ -91,6 +91,26 @@ def shared_namespace_metadata_keys(namespace)
metadata_fields
end

def aggregated_samples_count # rubocop:disable Metrics/AbcSize
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Please change the order of the first 2 lines of the function to

return sample_count unless shared_namespaces.any?

aggregated_samples_count = samples_count

This way the first line is the early return from the function, and we do not have to create/assign the new variable before doing so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! Switched in 73d2743

Copy link

Code Metrics Report

Coverage Test Execution Time
92.7% 9m7s

Code coverage of files in pull request scope (100.0%)

Files Coverage
app/components/namespace_tree/row/row_contents_component.html.erb 100.0%
app/models/group.rb 100.0%

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review Pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants