Fixes #38056 - Refresh content count action fails when count is set to {} #11244
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the changes introduced in this pull request?
Add check for smart proxy content_count being {}
Considerations taken when implementing this change?
We were handling the nil case but not empty? case, i.e {}
Added empty checks for content_counts in 2 places.
One for content_counts where we reinitialize it to { content_view_versions: {} } and for repositories where we need to handle content_counts[:content_view_versions][repo.content_view_version_id.to_s].empty?
What are the testing steps for this pull request?
In the console,
Try refresh counts action against any env/cv or global and the content count task will fail.
If you have some content_counts populated, pick any cv_version_id,
You can also try to test the empty hash case for cv version id keys.
Example:
sp.content_counts["content_view_versions"]["8"] = {}
Run refresh action for that cv_version from UI and see that it passes for this PR but fails without the PR.