Use group/count approach in annual report classes #32914
+52
−13
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.
First commit here adds spec coverage which actually exercises the ranking/ordering portion of these classes -- previous coverage asserted correct results/count, but only had one relevant record in returned hash.
Second commit converts some of these reports to rely on the implicit key->count map we get from doing a group by with a count. If the rails-internal
count_all
naming ever changed here, this query would break but these specs would also break, so I think that's safe to rely on here.Inspired by #32912 in that it's sort of a similar refactor/approach to making a map of counts.
Related to #31862 in that I think some of those improvements would make sense to resurrect if this merges (specifically, I think the scopes, constants, and private method extractions are useful - even if we dont take all of the more formatting-only type stuff).
Vaguely related to #32807 in that that's also about annual reports.