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

Levels within levels: BubbleChoice #41446

Merged
merged 6 commits into from
Jul 12, 2021
Merged

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Jul 6, 2021

Updates BubbleChoice levels to use the new many-to-many table for referencing sublevels. In the vein of #35827

Note that we did have to update the create_rollup_tables script as part of this work; thanks to Dave for pointing that out, because it was not caught by any tests. I spent some time trying to find a good place to add some, but came up short. So FYI that rollup tables remains an area of the codebase with poor test coverage.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@Hamms Hamms force-pushed the levels-within-levels-bubble-choice branch from 4d21415 to 69d3bfe Compare July 7, 2021 20:17
@Hamms Hamms marked this pull request as ready for review July 7, 2021 20:36
@Hamms Hamms requested review from davidsbailey and a team July 7, 2021 20:36
Copy link
Member

@davidsbailey davidsbailey 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, Elijah!

includes(:child_level).
where(kind: ParentLevelsChildLevel::SUBLEVEL).
order('position ASC').
map(&:child_level)
Copy link
Member

Choose a reason for hiding this comment

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

this looks like a good alternative to adding a new rails association for each sublevel type. rails associations do have the benefit that you can chain queries and other commands onto them efficiently, such as my_bubble_choice_level.child_levels.where(...), but until/unless we find we need that behavior I'm on board with this solution. optimize later :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a big part of the generalization stuff that I'm working on today is addressing this; my current strategy is to add an ActiveRecord Extension to the existing Association, so we can do stuff like my_bubble_choice_level.child_levels.sublevels.where(...)

Copy link
Member

Choose a reason for hiding this comment

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

wow, cool! I look forward to seeing what that looks like!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's my first draft: #41492

parent_levels(level.name).
map(&:script_levels).
flatten.
find {|sl| sl.script_id == script_id}
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest removing the warning comment from lines 53-54, since the new implementation looks more efficient.

@Hamms Hamms merged commit 6b92227 into staging Jul 12, 2021
@Hamms Hamms deleted the levels-within-levels-bubble-choice branch July 12, 2021 17:28
@Hamms Hamms mentioned this pull request Jul 13, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants