* Upgrade Rails to 6.1
* Switch to unreleased bullet
* Run rails app:update
* Add deprecation notices after reading changelogs
* Fix app:update error
* Move middleware in the correct place
* Temporarily disable ransack which does not support Rails 6.1
* Remove wrongly merged file
* Re-run spring binstub
* Fix double quotes
* Track ransack branch with Rails 6.1 support
* Fix deprecation
* Switch to Ransack 2.4 which supports Rails 6.1 rc1
* Fix missing default params for the duration substitution
* Fix new behavior of relation.pluck with contradictory queries
* Fix uploaders specs by tracking rspec-rails main repo
* Disable bullet temporarily
* Fix remaining fixture_file_upload usages
* Add default seconds for video article duration
* Trigger Travis CI
* Upgrade Rails to 6.1.0.rc2
* Remove file deleted on master
* Add Rails 6.1 gem to Gemfile
* Trigger Travis CI
* Revert "Disable bullet temporarily"
This reverts commit cee0c2ce61fb72cbc16d52c94b12ee681e873031.
* Fix bullet version
* Upgrade to acts-as-taggable 7 and fix conflict
* Update Gemfile and rspec-* gems
* Fix nokogiri in Gemfile.lock
* Switch to rspec-rails main branch
* Remove leftover vendored cached items
* Fix path for Rails 6.1
* Use latest release of erb_lint
* Re-run rails app:update to incorporate new changes
* Disable erb_lint's ErbSafety checks
* Fix Gemfile.lock and re-add platform specific gems of Nokogiri
* Add mini_portile2 as well
* Fix latest merge conflict by removing now unused faraday_middleware
* Upgrade to Rails 6.1.3.1
* Regenerate Gemfile.lock and vendor/cache
* Add x86_64 linux gem
* Mark spec as flaky
* Revert "Mark spec as flaky"
This reverts commit 3caba94b33645f9b59c84ba78ee8df042fc7aee0.
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
* User#followed_articles->Article.cached_tagged_with
This should improve performance on StoriesController#index
* Make cached_* work like their tagged_with cousins
* Swap to `cached_tagged_with_any`
This was using `tagged_with(tags, any: true)` before so this commit
swaps to using a scope that aligns with that method.
* Allow for searching by Tag models
* do the thing
* abracadabra run the build
* Add comment explaining Postgres regex anchors
* feat: add the two new models users_setting and users_notification_setting
* feat: add the settings and notification_settings table to the schema
* feat: add the user and notification models
* feat: add the user_id foreign key to the model
* chore: sneaky indent
* feat: add some fields from the profile attributes
* Revert "feat: add some fields from the profile attributes"
This reverts commit 376828746ded063a243505d317140fa5339227cf.
* chore: add some profile field attributes
* chore: remove language_settings
* chore: update indent
* chore: remove language_settings
* feat: changes to the tables
* chore: remove validation in favor of the foreign keys
* chore: add default for editor version
* Address PR review suggestions
* setting_spec.rb needs to be fixed; need help
* Working on PR review comments
* Continue with addressing PR review comments
* Remove normalize_config_values method; pass correct values from forms
* Address Travis failures
* revert some unnecessary changes in spec file
Co-authored-by: Arit Amana <msarit@gmail.com>
* Remove pro role on user, expose pro dashboard to all users as analytics
* Remove pro from Elasticsearch mappings
* Update user role docs to use :trusted over :pro
* Remove pro from Role model spec
* Remove more references to pro, as noted by @rhymes
* Added credits_awarded to /admin/badges forms
* Award credits only if badge has them
* Removed information about credits and listings in the new badge email when not needed
* Specs for number of credits awarded for badges
* Added missing newline
* Fix typo
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Improve new_badge_email.text.erb
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Fixed number of credits in notification
* Added specs for number of credits in notifications
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Add PgSearch to Listing model
* Working MVP - pre-optimizations
* Remove includes
* Update search_spec
* Add more specs
* Fix specs
* Refactor filter_by_category
* Update block parameter name
* Add published index to classified_listings table
* Preload user, organization, and listing_category
* Working MVP - pre-optimizations
* Refactor filter_by_category
* Update schema
* Fix schema for real
* Remove constant specs and make them private
* Adjust active_threads class method to display posts in homepage sidebar
* WIP: add specs around active_threads class method
* Uses newer AR query syntax in Article#active_threads
* WIP: Updates article_spec.rb to get tests passing
* WIP: Adjust test to return articles that dont fall into constraints
* Adjusts spec to update articles properly
* Adjust article.update_columns to match initial article columns
* Extracts .active_threads into a query object and removes class method
- Removes class method from Article model
- Removes class method tests from article_spec.rb
- Adds Articles::ActiveThreadsQuery to app/queries/articles
- Adds active_threads_query_spec.rb to spec/queries/articles
- Replaces Article.active_threads with Articles::ActiveThreadsQuery
in _homepage_content.html.erb and _sidebar_activity.html.erb
- General code clean up
* Rename number to count in Articles::ActiveThreadsQuery
* WIP new specs
* Update spec
* Repleaces let! with before block to appease rubocop
* Refactors Articles::ActiveThreadsQuery#call per PR review suggestion
* Calls Articles::ActiveThreadsQuery within articles_helper instead of view
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
* Step one in populating the reading list with PG
This first attempt tries to recycle the `Search::ArticleSerializer` which is only
used in input in ES, but we're using it in output in PG.
For this reason it's currently 15.55x times slower
* Serialize only what is requested by the frontend
`Search::ArticleSerializer` which is only used in ES in the indexing step aims
to add as much info as possible for broader purposes, in this case
(with serialization in output) we should aim to save only what's requested from
the frontend.
* Optimize selection of articles columns
* Select only needed columns for users
* Compute total of reading list items
* Attach the basic filtering based on PG on the search controller
* Restructure in methods
* Add tags support
* Use LIKE on articles.cached_tag_list
* Fix tags as nil
* Fix default pagination
* Add optional FTS for reading list
* Reworded the tags comment explaining why
* Add index to reactions.status
* Fix total counter in Preact readingList component
* Fix total count in reading list backend search
* Add GIN index to articles.cached_tag_list
* Add service tests
* Add search request specs
* Added missing early return
* Update spec/requests/search_spec.rb
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Extract MAX_PER_PAGE constant and add comments
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Add a failing test
This is failing because sponsorships are not removed by Users::Delete,
and raises a foreign key constraint error because user.destroy tries
to remove a referenced user.
* When destroying a user, destroy associated sponsorships
There is a `belongs_to` relationship in sponsorships, and a has_many
relationship in Organization, this adds a mirror relation on User with
the equivalent dependent destroy rules.
If an organization is removed, all sponsorships belonging to that
organization are removed too, and now, if a user is removed, all
sponsorships created by that user are removed.
Co-authored-by: djuber <djuber@forem.beta-reduction.com>
* Optimize Article.published scope
The index on `articles.published` is not being invoked due to lack of
diversity in the values in that column (it only has 2 possible values
because it's a boolean).
The index on `articles.published_at` is extremely diverse and will be
invoked any time it can reduce the scope of a query by an order of
magnitude or more.
On DEV, this does not change the row count for the scope:
irb(main):001:0> Article.where(published: true).count == Article.where(published: true).where(Arel.sql("published_at < now()")).count
=> true
The query plan for the `Articles::Feeds::LargeForemExperimental` service
invoked in the `Stories::FeedController#show` endpoint goes from this:
Planning Time: 0.271 ms
Execution Time: 329.258 ms
to this:
Planning Time: 0.330 ms
Execution Time: 0.468 ms
This is a reduction in query time of 99.7%
* Set published_at in articles factory
An article that is published should always have a `published_at`
timestamp
* Use Time.current for Zonebie
* Add clarifying comment to Article.published scope
* Generate timestamp in Ruby instead of SQL
I think using transactions for specs was interfering with comparing
timestamps generated in SQL, so this commit generates the timestamp in
Ruby.
* Move published_at outside of the transient block
This was causing articles to be marked as `published_at` right now even
if `published_at` was specified in the `FactoryBot.create` call.
* published_at: nil is no longer the factory default
* published_at is no longer nil by default
* published_at is no longer nil by default
* We didn't actually want to clear this published_at
This was intentionally left out to show that published_at does not get
cleared when we flip published true->false.
* feat: add the nested sidebar with some elements
* feat: create a tabbed nav item menu
* feat: add the tabbed nav_item partial to the views that need tabbed nav items
* fix: change variable back
* feat: style the sidebar a bit more
* chore: add some more styles
* feat: add a spec for the nested navigational items
* refactor: a more dynamic tabbed admin helper
* feat: add some more nav items
* fix: controller for reports
* refactor: shorthand if statement
* chore: add the whitespace back
* refactor: rubocop fixes
* chore: use any
* chore: remove whitespace
* refactor: rename the variable
* refactor: use a DSL style admin helper
* chore: variable renaming and routes
* rubocop: fixes
* refactor: move files to more apt places
* chore: keep overview as it was previously
* Update app/views/admin/secrets/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/shared/_tabbed_navbar.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/badges/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* chore: disable blocklength
* refactor: move the logic to the model instead of in the view
* chore: remove get_ prefix
* chore: move the request mangling to a helper that finds the controller and scope
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* refactor: Address feedback
* oops
* oops use tr
* feat: update specs
* feat: make the navbar a dropdown
* feat: add a cursor pointer to the dropdown
* feat: add the icons which results in changed data structure
* fix: badge achievements
* feat: rename to an html file, show and collapse links + show active links
* chore: rename tabbed view to an html file
* fix: scope should be apps not app
* feat: add icons for the admin menu
* feat: increase the margin left
* feat: move the overview into the feature flag block and add an icon
* chore:remove files
* chore: indent
* feat: update crayons -link to have no text-decoration
* feat: current link for a scope with one controller
* Update app/lib/menu.rb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/models/admin_menu.rb
Co-authored-by: Michael Kohl <me@citizen428.net>
* refactor: we added svg to the builder so remove it from creating the hash
* feat: undo change to crayons and add it to the admin stylesheet
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* refactor: change to use ul and li's + a button
* chore: add bracket to next line
* feat: add aria-page
* chore: remove brackets
* feat: added focus specifically for the sidebar
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
* chore: remove additional title
* chore: indent
* feat: add a visibilee keyword to the payload and set it to true by default
* feat: move the feature flagged routes into the correct sections
* feat: check if an item is visible before rendering it
* feat: amend the tabbed_navbar to be more accessible and add in visibilty checks
* chore: update comment
* chore: amend the styles
* chore: change url to path
* chore: comment
* test: add more tests
* Update app/assets/stylesheets/admin.scss
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Update app/views/layouts/admin.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* chore: merge
* feat: use focus for browsers that dont support focus-visible (I'm looking at you Safari) and move it within the crayons-link so we dont see it on mouse click
* WIP: first pass of stimulus controller code
* feat: interaction design
* chore: remove unnecessary condiition
* chore: only add transparent background when not the current link
* Update app/models/admin_menu.rb
Co-authored-by: Michael Kohl <me@citizen428.net>
* feat; comment explaining
* feat: add an id on the button to be clicked
* feat: disable currentNavItem
* chore: remove event params
* chore: update cursor
* feat: (safe fail)
only show the tabbed navbar when the roures contain values form the data structure
* chore: pass events through + tests
* trigger an onload event and test the disabling of the menu item
* refactor: tabbed menu items
* feat: account for the visibility of the feature flags
* chore: rubocop fixes
* chore: indentation
* feat: some refactors and updates for rubocop
* Update app/javascript/admin/controllers/sidebar_controller.js
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* feat: set to true
Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: rhymes <rhymes@hey.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Make definition of new user configurable
* Add new user configuration to config admin
* Only decorate on-demand
* Adapt new user logic
* Update app/lib/constants/site_config.rb
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
Fixes#13008
Add a test case for blackbox stability
This failed as expected on master and passed on this branch, when a
reaction (which would change the article's calculated score during
update) is added, the hotness should be stable, and not modified
during the second call to `#update_score`.
* Add PostgreSQL FTS for usernames
* Change profile_image_90 logic
* Make search_users private
* Add tsvector index on usernames
* Limit the number of search results
* Update index name
* Only check cache or database once
Since `@trusted` is a boolean true/false value, we can't use the
`@ivar || value` pattern, and want instead to check if the variable
has been defined.
Fixes#13006
* Add unit test around memoization behavior
In local testing I was able to get this to fail by changing the
2.times block to include `remove_instance_variable(:@trusted)` (so the
`allow...once` check is sufficient to ensure we are not calling the
cache more than once per instance when false).
* Add Search::Postgres::Tag to retrieve tags for autocompletion
* Add Search::Postgres::Tag in SearchController behind a feature flag
* Update spec/services/search/postgres/tag_spec.rb
Co-authored-by: Michael Kohl <citizen428@dev.to>
* Add index to tags.supported
* Fix hotness_score ordering
Co-authored-by: Michael Kohl <citizen428@dev.to>
* Limit number of mentions in a single comment
Ensure that no more than 6 users can be mentioned in a single comment
* Extract max user mentions into constant
* Check mentions but don't process them unnecessarily
* Add error message check to comment spec
* Add MAX_USER_MENTION_LIVE_AT to comments, plus specs
* Bump MAX_USER_MENTIONS to 7 for DEV Top Seven posts
* Add some clarifying comments around MAX_USER_MENTION limit
* Update app/models/comment.rb to use activesupport helper!
Co-authored-by: Michael Kohl <citizen428@dev.to>
* feat: add the nested sidebar with some elements
* feat: create a tabbed nav item menu
* feat: add the tabbed nav_item partial to the views that need tabbed nav items
* fix: change variable back
* feat: style the sidebar a bit more
* chore: add some more styles
* feat: add a spec for the nested navigational items
* refactor: a more dynamic tabbed admin helper
* feat: add some more nav items
* fix: controller for reports
* refactor: shorthand if statement
* chore: add the whitespace back
* refactor: rubocop fixes
* chore: use any
* chore: remove whitespace
* refactor: rename the variable
* refactor: use a DSL style admin helper
* chore: variable renaming and routes
* rubocop: fixes
* refactor: move files to more apt places
* chore: keep overview as it was previously
* Update app/views/admin/secrets/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/shared/_tabbed_navbar.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/badges/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* chore: disable blocklength
* refactor: move the logic to the model instead of in the view
* chore: remove get_ prefix
* chore: move the request mangling to a helper that finds the controller and scope
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* refactor: Address feedback
* oops
* oops use tr
* feat: update specs
* feat: make the navbar a dropdown
* feat: add a cursor pointer to the dropdown
* feat: add the icons which results in changed data structure
* fix: badge achievements
* feat: rename to an html file, show and collapse links + show active links
* chore: rename tabbed view to an html file
* fix: scope should be apps not app
* feat: add icons for the admin menu
* feat: increase the margin left
* feat: move the overview into the feature flag block and add an icon
* chore:remove files
* chore: indent
* feat: update crayons -link to have no text-decoration
* feat: current link for a scope with one controller
* Update app/lib/menu.rb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/models/admin_menu.rb
Co-authored-by: Michael Kohl <me@citizen428.net>
* refactor: we added svg to the builder so remove it from creating the hash
* feat: undo change to crayons and add it to the admin stylesheet
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* refactor: change to use ul and li's + a button
* chore: add bracket to next line
* feat: add aria-page
* chore: remove brackets
* feat: added focus specifically for the sidebar
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
* chore: remove additional title
* Update app/assets/stylesheets/admin.scss
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Update app/views/admin/shared/_nested_sidebar.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Update app/views/layouts/admin.html.erb
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* feat: use focus for browsers that dont support focus-visible (I'm looking at you Safari) and move it within the crayons-link so we dont see it on mouse click
Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: rhymes <rhymes@hey.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
When https://github.com/forem/forem/pull/11268 we didn't test it thoroughly and
thus didn't detect that it wasn't working correctly and that it
resulted in an empty string in the `<description>` field.
* feat: add the nested sidebar with some elements
* feat: create a tabbed nav item menu
* feat: add the tabbed nav_item partial to the views that need tabbed nav items
* fix: change variable back
* feat: style the sidebar a bit more
* chore: add some more styles
* feat: add a spec for the nested navigational items
* refactor: a more dynamic tabbed admin helper
* feat: add some more nav items
* fix: controller for reports
* refactor: shorthand if statement
* chore: add the whitespace back
* refactor: rubocop fixes
* chore: use any
* chore: remove whitespace
* refactor: rename the variable
* refactor: use a DSL style admin helper
* chore: variable renaming and routes
* rubocop: fixes
* refactor: move files to more apt places
* chore: keep overview as it was previously
* Update app/views/admin/secrets/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/shared/_tabbed_navbar.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* Update app/views/admin/badges/index.html.erb
Co-authored-by: Michael Kohl <me@citizen428.net>
* chore: disable blocklength
* refactor: move the logic to the model instead of in the view
* chore: remove get_ prefix
* chore: move the request mangling to a helper that finds the controller and scope
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* Update app/helpers/admin_helper.rb
Co-authored-by: rhymes <rhymes@hey.com>
* refactor: Address feedback
* oops
* oops use tr
* feat: update specs
* fix: badge achievements
Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: rhymes <rhymes@hey.com>
* Replace #active_help scope with #active_help class method
* WIP: Add tests around #active_help class method
* Refactor #active_help and update article_spec.rb tests to pass
* Replaces .active_help class method with .active_help scope
- Reverts change from scope to class method, back to scope
- Updates to use newer AR query syntax using endless ranges
- Refactors scope to be more concise
* Resourcify badge achievements
* Add test for single resource admin badge achievements
* Add badge and badge achievement roles
* Alphabetize (mostly) and cleanup syntax for easier writing
* Use quotes instead of %w and not outsmart myself :(
* alpha oops
* Add new table and model
* Store banned user username hash on delete
* Prevent previously banned user from signing up again
* Update method name
* Refactor code and add more specs
* Test improvements
* Don't override existing global flash
* Fix typo
* Update spec description
* Update schema.rb
* More schema.rb fixes
* Simplify spec
* Update migration
* Clean up migration
* Rename method
* Add DataDog counter
* Revisit error handling
* Remove spurious empty line
* Make model name more explicit
* feat: add tech_menu_items to the admin helper
* feat: add the tech resources to /admin if the user has the correct role
* feat: use a partial that will show the data update scripts in the navbar with the correct role
* chore: use a method
* test: chore
* feat: setup the data to need permission single_resource_admin with DataUpdateScript permissions
* chore: remove the if current_user.tech_admin?
* chore: remove line
* feat: add a DUS for single_resource_admin roles to be added to users with tech_admin roles
* fix: move all teh routes outside of the block where tech_admin is required.
* chore: use the constant and remove the method
* chore: add a comma
* Update config/routes.rb
Co-authored-by: rhymes <rhymes@hey.com>
* feat: add a tech admin role to the dropdown
* feat: add the tech admin role along with single_resource_admin
* chore: oops
* refactor: amend the spec to use let blocks
Co-authored-by: rhymes <rhymes@hey.com>
* Simplify special snowflake onboarding images and center around primary/secondary logos
* Remove left and right navbar customization
* Update app/lib/constants/site_config.rb
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Remove spec onboarding images
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Declare winner in feed_top_articles_query test
* Some WIP modifications to lfe
* Fix up tests and generalize
* Fix style
* Adjust tests to handle different field test scenarios
* Remove socre_randomness tests
* Fix test to fit stub
* Update app/workers/users/record_field_test_event_worker.rb