Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
There were still a few problems between versions, like:
insert_allof theBulkTogglerwith_featuresscope from thelib/togglefy/assignable.rbwith SQLResolution
Inheritance of the models && Loading models based on Rails version
There were still a few inheritance problems inside the
Togglefy::Featureand theTogglefy::FeatureAssignmentmodels. Also, there were in-model conditional validations to choose the best approach of a few things, which may cause performance problems.For this, we've changed it how the models load, by requiring a specific model based on the Rails version only once, during the initialize of the server:
Togglefy/app/models/togglefy/feature.rb
Lines 5 to 11 in 997882d
The above example applies also to the
Togglefy::FeatureAssignments.Thanks to that, we've stopped doing in-model conditional validations.
Building a feature's identifier
Older Ruby versions did not allow a keyword argument
separatorfrom the.parameterizemethod.Because of that, we've changed to
parameterizewithoutseparatorkeyword argument andgsubto change the-to_.insert_allof theBulkTogglerBefore Rails 6, there were no
insert_allmethod insideActiveRecord. So, because of that, we've implemented ainsert_allthat will only be used when the Rails version is lower than 6.Togglefy/lib/togglefy/services/bulk_toggler.rb
Lines 151 to 176 in 604a36b
This adds an inline conditional to check the Rails version, but since the bulk enable isn't an operation that's done a frequently, there's no need to improve it like we did with the models. There we had to do this because many checks were calling the models.
Building tracking analytics data
The yet unreleased analytics feature was using a
filter_mapmethod to build the analytics/tracking data of a feature.That's a problem because this method was only introduced in Ruby 2.7 and we say we support Ruby 2.4.10. So we changed that to a simpler
map.Writing the
with_featuresscope from thelib/togglefy/assignable.rbwith SQLThe
with_featuresscope was having a problem with Rails 4.2.8. It was losing context/alias of the join with thefeature_assignments, so when entering the where clause wasn't working because it could not find the tablefeature_assignments.Well, it wasn't able to find it because it didn't exist. It's supposed to be
togglefy_feature_assignments.Because of that, we've decided to write the join with SQL to force the alias and make sure it will remember it.
Togglefy/lib/togglefy/assignable.rb
Lines 29 to 37 in 604a36b
Impacted processes/locations
Togglefy::FeatureTogglefy::FeatureAssignmentTogglefy::ScopedBulkWrapper&&BulkTogglerAnalyticsAssignableReferences
#45