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)
* 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
* 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
* 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>
* Adds ability for admins to create new tags via /admin/tags
* Merge branch 'master' of github.com:forem/forem into fdoxyz/admin-new-tags-11026
* Fix rubocop pre-hook
* UI Tweaks
* replaces show with edit action & other minor changes
* Reverse unrelated changes
* Removed more unrelated edits
* Fix specs
* Fix moderator link
* Allow authors to restrict which emails can sign up
* Add form and tests
* Check for email presence in allowed email flow
* Fix test domains
* Fix codeclimate issue
* Simplify admin and add links to help pages
* Add line
* Add line
* Update app/views/layouts/admin.html.erb
* Update app/controllers/admin/configs_controller.rb
* Move svg to own file
* Adds image URL validation to image URLs in configs_controller.rb
* Adds additional image URLs to #valid_image_url in configs_controller.rb
* Adds tests around valid image URLs to configs_spec.rb
* WIP: sets strict conditions for before_action
* WIP: comments out unused code for draft PR
* WIP: cleans up configs_controller.rb for draft PR review
* Renames constant to more explicit IMAGE_FIELDS in configs_controller.rb
* Removes unnecessary comments from admin/configs_spec.rb
* Checks for matching keys in params and IMAGE_FIELDS in configs_controller
* Refactors #valid_image_urls and #valid_image_url in ConfigsController (THANK U, ANDY)
* Refactors image-related code and error messages in Admin::ConfigsController
* Renames expected_image_url to invalid_image_url and removes useless test
* Fix: update the tests to contain valid image urls so that they pass the validation.
* Adjusts tests & VALID_URL regex to validate images rather than image-specific URL
* Replaces $ with \z per Rhymes suggestion and feedback
* Adds accidentally removed code
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
* Update shell version when admin action taken
* Update app/controllers/admin/application_controller.rb
Co-authored-by: Alex <alexandersmith223@gmail.com>
Co-authored-by: Alex <alexandersmith223@gmail.com>
* Don't add to mailchimp for N/A circumstance
* Use class << self over self. methods
* Refactor and make add/remove tag mod idempotent
* Add missing param wiki_body_markdown
* Add errors_as_sentence b/c Tag not inheriting from AppRecord
* Refactor and Crayonsify tag page
* Use proper for attr to make label checkable
* Crayonsify moderator section
* Make placeholder white
* Remove remote: false for sync form submit
* Fix more merge conflicts
* Minor styling adjustments
* Fix color field value
* Don't add to Mailchimp community mod list if not enabled
* Add tests for new tag mod routes
* Add missing line oops
* Use self.method over class << self for new Rubyists
* Use more efficient query for getting tag mods
* Use parentheses to follow convention
* Use cleaner way of routing and controller
* Update tests to match new configuration
* Added form fields for the admin podcasts dashboard.
* Updated podcasts_controller.rb; Added parameters to the allowed params.
Updated edit.html.erb; Removed duplicated field.
Updated podcasts_spec.rb; Updated test.
* Fixed a typo.
* Refactored test which hopefully fixes the build
* Added missing comma.
* Added file fixture uploads.
* Fixed a typo.
* Update spec/requests/admin/podcasts_spec.rb
Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
* Again fixed another typo.
* And again fixed another typo.
* Fixed merge conflicts.
Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
Co-authored-by: rhymes <rhymes@hey.com>
* Add feature flag for profile admin section
* Fix spec description
* Also remove profile admin link from sidebar
* Disable profile admin routes based on feature flag
* Minor fixes
* Remove unnecessary object from spec
* Refactor AdminHelper
* Fix specs
* Fix remaining specs
* Refactors #update in Admin::ArticlesController and articles_spec.rb
- Adds article.update to #update in the controller
- Shifts the update of co_author_ids further down in #update
- Adds additional tests to articles_spec.rb
- Refactors existing tests in articles_spec.rb
* Adds a gaurd clause to Admin::ArticlesController and refactors specs
* Removes ! from article creation in articles_spec.rb
* Adds new and edit views for events and removes them from the index view
* Fixes formatting issues in /admin/pages/index.html.erb
* Refactors /admin/events partial, new, and edit forms
* Updates admin_events routes to include all routes except destroy
* Refactors Admin::EventsController and adds #new and #edit actions
* specs: Adjusts admin_creates_new_event_spec to work with /admin/event changes
* Refactors the Admin::EventsController, routes, and events index even further
- Adds back placeholder text in Events form
- Removes unnecessary code from controller
- Reverts changes to routes
- Adjusts event_cover_image size on index.html.erb
* specs: Adds tests around creating and updating events to events_spec
* Adds pagination to Admin::EventsController #index to cap events at 20 per page
* Removes .all from Admin::EventsController and adds a line to index.html.erb
* Uses crayons classes for _event_form.html.erb
* Improve error messages and validation for pages
This could probably be cleaner, but I wanted to avoid changing behavior,
so there is a bit of redundancy.
In this commit, I also had to convert an if statement to a case
statement for Rubocop.
* Add system spec for editing pages
* Use errors_as_sentence
* Hooked "Enable" button to hidden checkbox
* Hooked "Close" button to close email settings and show "Enable/Edit" button
* Additional hookups
* Start building generalized Modal blocks
* Everything hooked up except styling and a few Qs
* last of the hookups; ensure logic flow
* clean up
* specs to cover email auth refactor
* Fix bug surfaced by Vaidehi
* Incorporate PR feedback
* prevent email auth disable if invite-only-mode
* adjust emailAuthModal body text
* Sundry improvements
* Last-mile tweaks
* Trying to get 3rd party auth deselect to work
* delete unnecssary function
* remove superfluous comment
* Move inline styling into CSS file
* Incorporate PR feedback
* Incorporate more PR feedback
* Make Confirm btn intent clearer
* Add TODO comment
* Fix missing spaces in description of suggested_users
* Add config to use suggested_users instead of auto-generated suggestions
* Improve determine_follow_suggestions method
* Update app/lib/constants/site_config.rb
Improve the wording of the description of prefer_manual_suggested_users
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Apply new style to prefer_manual_suggested_users checkbox
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Update data exporter to handle admin send
* Match button with everything else
* Use proper redirect path
* Stub SiteConfig definition instead of setting it
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
* Removed if statement by accident oops
* Remove non-functional boolean param and pass email directly
* Use refinement to conv to boolean instead of JSON.parse
* Rename to StringToBoolean
* Use 'using' in proper scope (not in method)
* Rename to_bool to to_boolean
* Refactor if statement, thanks rhymes!
* Fix small bugs in tests
* Remove tracking for export_email b/c no @user
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
* Adds ability to publish/unpublish Podcasts via /admin/podacasts/id/edit
- Moves ability to Admin to remove reliability of resource_admin
- Adds published to podcast_params in Admin::PodcastsController
* Adds a test to check the successful publishing of a podcast in podcasts_spec.rb
* Reverts change to podcast.reload in podcasts_spec.rb
* Bust caches when navigation links are changed
* Remove extra line
* Add admin_action_taken_at to SiteConfig to reference later
* Format timestamp with rfc3339 and fix Specs
Co-authored-by: mstruve <mollylbs@gmail.com>
* WIP: Gives Admins the ability to delete invitations from /admin/invitations
* Refactors #destroy to properly delete invites, redirect, & display messages
* Adds additional flash message and makes existing messages more explicit
* Adds spec to test the deletion of invitations in admin/invitations
* Adds a new admin setting for experience levels.
This is used in the post management UI to determine the range of experience. These values fallback to the ones we currently see in DEV, Total Newbies and Senior Devs. There is also a removal of the word coding when talking about experience level, since the context for each forem instance should be implied when referencing experience.
* Cleans up experience defaults
* Fixes instance_of usage
* feat: allow a page to override the code_of_conduct, terms and privacy page
* feat: let privacy policy also use a partial for its contents like coc and terms
* feat: show the defaults or the pages
* specs: add tests for the overrides
* feat: update some styles and make use crayons buttons
* fix: update order of test items
* spec: fix
* reactor: move this whole section in the if
* feat: updates
* fix: code climate + travis
* more codeeclimate