* Rename comment-mentioned-user class added by Html::Parser
* Add DataUpdateScripts for resaving articles, comments, and messages
* Swap order of messages and articles DUS
* Use trigger and tsvector column to speed up reading list search
* Add organization destroy spec and todo note
* Fix failing data update script due to not null constraint
* Remove the leading anchor in the trigger regexp
* Fix reading list specs
* Address feedback
* Move authors followers out of Notifications::NotifiableAction::Send and into Article model
* Rename authors_followers to followers
* Update followers method in service, oops
* Update app/services/notifications/notifiable_action/send.rb
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Michael Kohl <citizen428@dev.to>
* Rename banned and comment_banned roles
* Add data update script to rename roles containing 'ban'
* Add named error for Suspended users
* Update unidiomatic method names
* Rename misc banned to suspended
* Apply suggestions from code review
Co-authored-by: Michael Kohl <me@citizen428.net>
* Add unit tests for suspended methods
This commit also adds TODO comments for removing banned and
comment_banned from the codebase after data update scripts have
successfully run on all of our Forems.
Co-authored-by: Michael Kohl <me@citizen428.net>
* Limit mentions in articles
* Bump MAX_USER_MENTION_LIVE_AT to April 7th, 2021 UTC time
* Use stubbed constants in article and comment specs
* Add TODOs around extracting MAX_USER_MENTIONS into constant
* 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
* 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>
* 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.
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`.
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.
* 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
* 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
* Allow any admin to publish welcome thread
* Update app/models/article.rb
Co-authored-by: rhymes <rhymes@hey.com>
* Fix specs by making user for welcome thread an admin
* revert spec changes and update code to include either admin, super_admin, or site mascot
* add specs for scope
* Modify tests and include mascot user
* Fix test
Co-authored-by: rhymes <rhymes@hey.com>
Co-authored-by: mstruve <mollylbs@gmail.com>
* Adds a lower() query to the DB in Stories#show
* Restructure spec
* bypass article callbacks in order to test edge case
* Fixes spec
* Change the approach to unsure downcase path in Article model
* Move .downcase call to set_caches before_save callback
* Adds data update script for fixing offending Article paths
* Moves model tests to correct block
* Apply suggestions from code review
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
* Implement changes
* display "Suspended" if user role.name is banned
* Correct equality symbol
Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Michael Kohl <me@citizen428.net>
* Replaces second_user_id and third_user_id with co_author_ids on the Articles table
* Adjusts migration that adds co_author_ids to also add array: true
* Replaces second_user_id and third_user_id with co_author_ids in all applicable files
- Use co_author_ids in _individual_article view
- Use co_author_ids in articles and stories controllers
- Use co_author_ids in article and podcast_episode models
- Use co_author_ids in article_dashboard
- Use co_author_ids in comments_helper
- Use co_author_ids in articles_spec
* Replaces second_user_id and third_user_id with co_author_ids in article.rb model
* Remove unused #assign_co_authors method from the Stories::Controller
* Add #co_authors and #co_author_name_and_path to article_decorator.rb
* Adds a descriptive form field for co_author_ids for Admins in /admin/articles
* Adds a conditional in article/show.html.erb to render co_author names on an Article in a human-readable way
* Replaces get_co_author_name_and_path with proper method name, co_author_name_and_path in show.html.erb
* Adds latest schema to (hopefully) resolve Travis conflicts
* Adds the safe operator to show.html.erb
* Adjusts articles_spec.rb to use an array in the first test
* Replaces unless &.empty? with if ./present? in articles/show.html.erb
* Replaces second_user_id with co_author_ids in stories_show_spec.rb test
* Replaces elsif with else in articles/show.html.erb
* Cleans up show.html.erb by removing conditional in favor of decorator method
* Refactors splitting of params in Articles::Controller and optimizes query in #co_authors
* Reverts removal of second_user_id and third_user_id and migration file
* Adds a data_update script to update co_author_ids with existing second and third user_ids
* Adds validations to co_authors and flash_messages to indicate whether an update was successful or not
- Adds to methods to article.rb to validate the IDs of co_authors and authors
- Adds flash messages to the Admin::Articles::Controller and a redirect to the show page
- Removes the JS highlighting upon submit when updating an Article in Admin
- Refactors #update action in Admin::Articles::Controller
* Adds tests to article_spec.rb around co_author_id validations in article.rb
* Adjusts #validate_co_authors_must_not_be_the_same to use .include? instead
* Uses Field::Select.with_options in article_dashboard.rb to properly display co_author_ids
* Reverts removal of assigning co_author_ids in the Stories::Controller
* Adjusts error message and adjusts return logic in article.rb (thanks, Fernando!)
* Fixes failing article_spec.rb test that checks for co_author_ids uniqueness
* Adds a default array to co_author_ids and checks if they are .blank?
* Refactor data_update script to use a single SQL statement (thank you, Michael)
* Preserve array order of co_author_ids in article_decorator.rb
* Add db file for default: []
* Add validation to fix bug related to text inputs and invalid users when adding co_authors
* Adds tests to ensure that co_author_ids are both an integer and an integer > 0
* Updates admin/articles_spec.rb to default [] instead of nil
* Adjusts validations in article.rb to be DRY-er and more consistent
* Consolidates validations further
* Refactors validations in article.rb to use procs
* Refactors data_update script to remove nil values from array
* Add FK between ahoy_messages and feedback_messages
* Add FKs between articles.second_user_id, articles.third_user_id and users
* Fix associations and specs
* Add more validations
* Remove FKs to articles.second_user_id and .third_user_id as they are about to be removed
* Adds second_user_id and third_user_id to Admin::Articles::Controller and Article model
- Add second_user_id to #update
- Add third_user_id to #update
- Add second_user_id to #article_params
- Add third_user_id to #article_params
- Add second and third user_ids to :limited_columns_internal_select
* Adds a second_user_id and third_user_id form field to _individual_article.html.erb
* Adds tests around adding a co-author and multiple co-authors to an article in articles_spec.rb