When `acts-as-taggable-on`'s `.tagged_with()` is used with `any: true`,
the gem will use `SELECT *` regardless of any previous (or following) requests
of selecting a limited amount of columns.
Given that the `articles` table has [73 columns](https://dev.to/admin/blazer/queries/314-number-of-columns-in-all-tables)
that will amount to wasted RAM memory for columns we don't need.
By "unscoping" any previous `select()` we can optimize used memory.
Before:
```ruby
[24] pry(main)> Article.tagged_with([:ruby], any: true).select(:id, :name).to_sql
=> "SELECT \"articles\".*, \"articles\".\"id\", \"name\" FROM \"articles\" WHERE EXISTS (SELECT * FROM \"taggings\" WHERE \"taggings\".\"taggable_id\" = \"articles\".\"id\" AND \"taggings\".\"taggable_type\" = 'Article' AND \"taggings\".\"tag_id\" IN (SELECT \"tags\".\"id\" FROM \"tags\" WHERE (\"tags\".\"name\" LIKE 'ruby' ESCAPE '!')))"
```
Note, how the SQL query is `articles.*, articles.column_a`
After:
[25] pry(main)> Article.tagged_with([:ruby], any: true).unscope(:select).select(:id, :name).to_sql
=> "SELECT \"articles\".\"id\", \"name\" FROM \"articles\" WHERE EXISTS (SELECT * FROM \"taggings\" WHERE \"taggings\".\"taggable_id\" = \"articles\".\"id\" AND \"taggings\".\"taggable_type\" = 'Article' AND \"taggings\".\"tag_id\" IN (SELECT \"tags\".\"id\" FROM \"tags\" WHERE (\"tags\".\"name\" LIKE 'ruby' ESCAPE '!')))"
```
`articles.*` is gone :-)
- https://github.com/mbleigh/acts-as-taggable-on/issues/936
- 47da5036de/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb (L2-L8)
* Log params[:token] and destroy_token to Honeycomb when token mismatch
* Refactor #confirm_destroy and add Honeycomb fields for error logging
* Add tests around Honeycomb error logging in #confirm_destroy to spec
* Remove logging of user to Honeycomb in #confirm_destroy and in spec
* Frontend Ready for Connect Report Abuse
* add feedback api
* js defination fix
* Added Hooks to the Component
* add json response in feedback
* Block popup added
* fix render issue
* Made changes in internal view
* change error message
* Added few design changes =
* add test cases
* Update app/javascript/chat/actions/requestActions.js
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* add PR suggestions
* add backend test cases
* report abuse form close
* Update app/javascript/chat/actions/requestActions.js
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* Update app/javascript/chat/ReportAbuse/index.jsx
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* add test cases
* Update app/javascript/chat/ReportAbuse/index.jsx
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* Update app/javascript/chat/ReportAbuse/index.jsx
Co-authored-by: Marcy Sutton <holla@marcysutton.com>
* Update app/javascript/chat/ReportAbuse/index.jsx
Co-authored-by: Marcy Sutton <holla@marcysutton.com>
* group the fieldset
* fix report abuse api
* fix test case
* fix request test case
* fix typo
* cleaned up markup in report abuse component.
* Fixed spacing between abuse options.
* Fixed wording in report abuse confirmation.
* Removed unnecessary data-testid and aria-label attributes.
* Added some top margin to the report abuse form.
* Update app/javascript/chat/message.jsx
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Added a legend to the the fieldset.
* Update app/javascript/chat/actions/requestActions.js
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Sarthak <7lovesharma7@gmail.com>
Co-authored-by: Narender Singh <narender2031@gmail.com>
Co-authored-by: Marcy Sutton <holla@marcysutton.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Michael Kohl <citizen428@dev.to>
* Adds guard clauses and better error messages to UsersController #confirm_destroy
* Adds tests around guard clauses in UsersController #confirm_destroy
* Adds a custom error for invalid tokens in UsersController#confirm_destroy
* Refactor user_destroy_token.rb initialize method to be more succinct
* Removes unnecessary code from user_self_destroy_spec.rb and fixes failing InvalidToken spec
* Reworks code in #confirm_destroy to be consistent with other #destroy methods
* Adjust token mismatch test to use mismatched tokens
* Refactors #confirm_destroy and adds a before_action to Users::Controller
- Reworks the logic within #confirm_destroy and removes excess code
- Adds set_or_sign_in_user before_action for #confirm_destroy
- Removes custom InvalidToken error message
* Cleans up spec and adds an additional test around logged out user edge case
* Fixes failing tests due to changes in #confirm_delete flow
* Adjusts test logic in user_self_destroy_spec.rb
* Refactors code by removing custom before_action and rewriting conditionals
* Create new MarkdownProcessor::Fixer services
* Remove old MarkdownFixer
* Code cleanup
* Capitalize Base in code comments
* Remove comments related to inheritance
* Add fix_methods method to hold METHDOS constant
* Use Ransack for admin/tags
* Update admin tags index to use search with Ransack
* Add feature to sort tags in /admin/tags
* Add test for viewing /admin/tags pages
* Add aria labels for sort links
* Make links a bit more accessible
* Refactor test a bit
* Account for URL encoding when redirecting to /confirm-email
* Fix failing spec
* Use correct method to encode + and @
* Fix test
* Don't encode things I don't need to (thanks Nick)
* Add .to_s to ForemInstance.deployed_at
* test: could it possibly be holding onto the cached value across the tests
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
* WIP: release footprint in the admin UI
* feat: show the commit ID and the date
* chore: change env optional to empty string
* fix: change the FOREM_BUILD_DATE to RELEASE_FOOTPRINT
* feat: add Not Available as a last option
* test: last deployed time and latest commit id
* feat: update the way we change the env variable!
* fix: we need to set the RELEASE FOOTPRINT so that this clause is not hit - `return path if release_footprint.blank?`
* feat: add a Forem Instance Model
* chore: rename variable
* feat: use the new model that we created
* feat: Update the Forem Instance model to remove Not available from the model method and add it to the view layer
* test: Forem Instance model to return the correct values when present
* feat: use Forem.deployed_at instead of the Application config directly
* chore: remove the initializer
* feat: rename the data keys to reflect what it does
* fix: oops evaluate the var
* refactor: static values that can never change during the lifetime of the app should be constants
* chore: setup the test to have a release footprint before the test gets executed
* chore: remove the methods
* revert to method + cache
* revert to using method
* reset the instance variable
* Add script to remove feature flag
* Remove :feeds_import feature flag and RssReader and related classes
* Change Feeds::ImportArticlesWorker signature to support Sidekiq Cron serialization
* Replace RssReader::Assembler with Feeds::AssembleArticleMarkdown
* Removing Assembler
* Create Bufferizer::MainTweet service
* Create Bufferizer::SatelliteTweet service
* Rename text to tweet
* Create Bufferizer::FacebookPost service
* Create Bufferizer::ListingsTweet service
* Remove old Bufferizer
* Update spec wording
* Update admin_id argument
* Use constants for size limits
* feat: add a basic table template with the basic info for the data scripts
* feat: add nav element to sidebar
* feat: add twemoji
* feat: success and failed icon
* feat: don't wrap the status title
* feat: make data update scripts accessible only be tech_admin
* chore: add the file name to the table
* test: write tests for the data_update_script_controller
* chore: remove icons and add status
* Add query string option for filtering latest articles
* Show last featured articles on /feed/latest
* Add handle_latest_feed method
* Add support for page query
* Use better naming
* Use functionailty of LargeForemExperimental#latest_feed instead of calling the service
* Include 'not featured articles' on feed
* Cleanup
* Add earlier_than to Feeds::Import
* Ignore feeds that have been imported in the last 4 hours
* Make earlier_than mandatory in Feeds::ImportArticlesWorker
* Replace follows#update with follows#bulk_update
* Allow follows#bulk_update to receive multiple follows and remove follows#update
* Add FollowPolicy#bulk_update? and remove update?
* Combine save button into one in following_tag.html
* Rename follows_update_spec to follows_bulk_update_spec and update
* Update buildTagsHTML to conform to the view
* Allow scrolls down dashboard test to update multiple tag values
* Includes follower and followable in follows#bulk_update
* Mark and pass changed field.
* fix typo in html
* Update follows in transaction
* Extract js script to another file and update view
* Rename disableUnchangedButton.js to dashboardTagsDisableUnchangedButtons.js
* Removes collective_noun and collective_noun_disabled from app
* Config Generalization: replaces community_qualified_name with community_name
- Generalizes SiteConfig after the removal of collective_noun field
- Updates copy where necessary to be readable with community_name
- Makes the community_name SiteConfig description more explicit
- Adds flexibility for Admins by removing appended "community"
* Adds a data_update script to remove collective_noun and collective_noun_disabled
* Removes appended community from stories_controller.rb
* Removes unnecessary quotation marks around SiteConfig.community_name.to_s
* Makes SiteConfig community_name description more explicit
* Removes topic from #email_from and replaces arg with _
* Removes argument from #email_from (facepalm)
* Reverts changes to application_mailer and notify_mailer_spec
* Removes default "Community" topic from application_mailer and makes topic optional
* Refactors #prepopulate_new_form to resolve Code Climate failures
* Refactors #email_from even further by use of a ternary operator per review suggestion
* Simplifies the data_update script used to remove collective_noun per review request
* Adds a data_update script to append community to community_name
* Updates data_update script to correctly append Community to community_name
* Removes RemoveCollectiveNounFromConfig and updates other script
* Removes superfluous false from data_update script
* Updates data_update script to be more idiomatic
* Remove GitHub repositories when user deletes their own GitHub identity
* Remove GitHub repos also from the admin remove identity
* Add a notice in Settings/Extension
* Add data update script to cleanup orphan GitHub repos
* Add gem omniauth-apple
* Integrate omniauth-apple
* Integrate callback
* Add fields
* Add tests, fix bugs and make it all work
* Show only enabled providers for the current user
* Add default profile image for Apple
* Remove localhost patch
* Bring over the changed Apple username if the user changes it
* More specs fixed
* Incorporate feedback from PR
* Fix specs
* Simplify code and fix spec
* Fix Broadcast generators to take into account the new provider
* Fix spec
* Generate a truly unique apple_username
* Fix user specs
* Add omniauth-apple-0.0.2 to vendor cache
* Fix merge conflict and spec
* Update VCR fastly sloan cassette
* Revert "Generate a truly unique apple_username"
This reverts commit 2462875575b0bbd6b3c1d56b25afcd3189671608.
* Fix user specs
* Fix specs
* Fix specs
* Hide Connect Apple button behind a feature flag
* Revert "Hide Connect Apple button behind a feature flag"
This reverts commit 105bde0373389a4eb9b6e948f60734c7e0e99cba.
* Fix line lengths
* Fix spec
* ES tag
* CSRF bypass for Apple callback
* custom user_nickname in Apple provider with small tweaks + omniauth-apple bump
* Fixes username specs
* Makes Apple users default image Users::ProfileImageGenerator
* Fallback to mascot_image_url in test environment to avoid breaking Travis
* Fixes Apple CSRF error + makes default nickname more readable
* Trigger Travis
* Better devise config
* Apple SiteConfig entires in /admin/config
* Fixing specs
* Adds beta_access? to Authentication::Providers::Provider
* Fixes specs
* Codeclimate double quote fix in Gemfile
* Fixes /admin/config allowed params & adds feature flag for provider beta_access?
* Remove Enfile & adds temporary docs
* Adds custom apple auth provider settings
* Fix authenticator spec
* Fix configs spec (use last instead of first to avoid apple special case)
* Remove dangling fields from /admin/config
* updates feature flag
* More test fixes
* Hide config behind feature flag too
* omniauth-apple bump
* Takes care of edge case fallback
* Reverse apple_username update
* Adds auth_time to info hash in apple omniauth mock
* Switch to next instead of nesting for feature flag
* Fixes CVE-2015-9284
* Fixes specs after auth providers initiatior refactor from GET to POST
* Spec fixes
* More spec fixes
* Fix Rails codebase reference link
Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
* added podcast_owner role
* changed view files
* added owner functions
* changed function name in view file
* removed owner role
* removed changes in view file
* controller changes
* added permitted attributes
* fixed the failing tests
* deleted the remove_owner feature for now
* changed controller
* fixed the build error
* added route to add_owner
* added another test
* made suggested changes
* Display gdpr delete requests for deleted users in admin
* Added a test for destroy a gdpr request
* Reorganized gdpr requests menu
* Update schema version
* Added a link to the flash notice after user delete by admin
* Fix namespace for tests
* Aligh schema.rb with master
* Added a missing newline
* Removed unused partial
* Fix typo
Co-authored-by: Michael Kohl <me@citizen428.net>
* Replaced string with symbols for AR
Co-authored-by: Michael Kohl <me@citizen428.net>
* Added an AuditLog record on gdpr delete confirmation
* Make email and user_id required in Users::GdprDeleteRequest
* Checked out package.json from master
* Fix Gdpr => GDPR
* Added missing space
* Remove unneeded freeze
Co-authored-by: Michael Kohl <me@citizen428.net>
* Render left sidebar attributes on profile
* Display header profile fields
* Make changes to protect DEV data
* Don't render DEV header fields twice
* Wrap profile UI changes in a FeatureFlag
* Add spec to test mulitple display areas
* Use select over reject
Co-authored-by: Michael Kohl <me@citizen428.net>
* Move comment for documentation generators
* Update dev profile fields csv data
Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>