* Revert "Revert "Add (updated) mention autocomplete to post comments (#13061)" (#13116)"
This reverts commit e28bde043c.
* Fix issues with editing comments and arrow key navigation, update tests
* Update app/javascript/crayons/MentionAutocompleteTextArea/MentionAutocompleteTextArea.jsx
Co-authored-by: Nick Taylor <nick@forem.com>
* refactor adding of attributes
* destructure
Co-authored-by: Nick Taylor <nick@forem.com>
* Working version of Runtime Filter with banner behind Feature Flag
* First attempt to add a cypress test
* Adds simplified test
* Cleanup global references
* Add multi-platform e2e test
* Use --runtime-display var with fallback to block
* Update app/assets/javascripts/initializers/runtime.js
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Add FeatureFlag stub to fix unrelated specs
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Reinitialize variables in instantclick context
* Refactor and follow instantclick loading pattern elsewhere
* Actually fix conflicts oops
* Add navigation links to e2e seeds
* Add e2e tests for More button with instantclick
* Set element's onclick directly as opposed to use addEventListener
* Remove unnecessary null check
* Check for visibility instead of class list
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Chain .should since we can 👍
* Update test and seed data to account for merge
* Use .findAllByLabelText instead of .get
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* 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>
We have a btree index on this table but it is not invoked with a `LIKE`
operation that uses `%` - only when using `LIKE` with an exact match.
This query is DEV's second-most intense query by total time spent with
a p50 latency of ~130ms. This index brings it down to 5ms at p90.
* change tag to h2 to avoid the overflow
* delect commit
* make the font size bigger when screen size is more than 1000px
* Update chat.scss
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Michael Kohl <me@citizen428.net>
* 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 save_valid_attributes method in profile
* undo save_valid_attributes method
* Render the settings page with user entered params incase of failed update
* Added credits_awarded to badges
* Data update script for updating credits_awarded
* Data update script for updating credits_awarded
* Added null: false to badges.credits_awarded
This one file seems to be associated with segfaults we're observing in
TravisCI.
To narrow down the source of the issue, disable this set of tests. (If
segfaults continue, this was not the cause and should be re-enabled).
Co-authored-by: djuber <djuber@forem.beta-reduction.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.
* Ensure loggd out user data is not in the document
* Use delete operator to remove user property
Another function relies on this value not existing. If this property
exists, but is set to undefined, it will not behave as expected.
* Add tests to verify user data does not persist in the DOM after logout
* Update cypress/integration/loginFlows/userLogout.spec.js
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
* Fixup: Test localStorage for user data
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>