Commit graph

4965 commits

Author SHA1 Message Date
rhymes
def0cf2437
Optimize column selection for articles belonging to "any" given tag (#12420)
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)
2021-01-25 17:34:10 +01:00
Rafi
b13c76f405
Prevent text overflow of follow button (#12422) 2021-01-25 17:29:10 +01:00
Ben Halpern
8b5b19bfa8
Fix flash of unstyled content (#12385)
* Fix flash of unstyled content

* Fix test context

* Add missing user in test

* Add qualifier argument
2021-01-25 10:49:58 -05:00
Julianna Tetreault
2cd523f811
Update Tag Link to Route to Proper Admin Page (#12391) [deploy]
* fix: update admin tag edit page link to include /edit

* Update admin tag edit page link to be more descriptive
2021-01-25 08:25:39 -07:00
narender2031
06a6191424
fix ui issue to display bug (#12365) 2021-01-22 15:47:19 -05:00
cyrillefr
a3e76b6d09
Refactor magic numbers for /comments rendering (#12323)
* Refactor magic numbers for `/comments` rendering (#11594)

* Update comments_helper adding constants & accessor methods

* Refactor stories_controller replacing hard coded values by helper call

* Refactor _comments_section view accordingly with helper calls

* Add test to specs (view_user(index|comments)) accordingly

* Refactor magic numbers for `/comments` rendering

Small changes after initial review

* Change constante to more explicit names
* Change one helper method name
* Pluralize in view

Co-authored-by: rhymes <rhymes@hey.com>
2021-01-22 10:55:44 -06:00
Rafi
931d9169fd
Fixing link focus (#12362)
* Fixing link focus

1. Removing display content from link
2. Removing extra margin at the top of link
3. Adding before link

* Extending crayon-fields and removing margin-top
2021-01-22 09:26:51 -05:00
Fernando Valverde
88bd3a1069
Replace authentication_enabled_providers.include? with helper method (#12379)
* Replaces authentication_enabled_providers.include? with helper authentication_provider_enabled?

* Fix typo
2021-01-22 07:54:10 -06:00
Michael Kohl
6afaa25f50
Fix accidental publishing of draft articles (#12288)
* Fix accidental publishing of draft articles

* Add regression spec

* Fix spec
2021-01-22 08:47:16 +07:00
Julianna Tetreault
2ebe55fc22
Log Relevant Data from Self-Deletion Flow to Honeycomb (#12369) [deploy]
* 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
2021-01-21 17:00:10 -07:00
Julianna Tetreault
63a1484a56
fix: remove extra href from admin/articles/index.html.erb (#12373) [deploy] 2021-01-21 16:32:18 -07:00
Andy Zhao
7c47d351f0
Cache only the static badge achievement data for notifications (#12368)
* Cache only the static badge achievement data for notifications

* Cache the image too, but at what cost...? 🤔

* Add data update script to clear badge achievement notifications' caches

* Remove unnecessary cache for badge achievement notifications
2021-01-21 17:03:42 -05:00
Rafi
940c7ee37d
Adding aria labels and role to onboarding modal (#12363)
1. Adding role dialog
2. Adding aria-labelledby and aria-describedby
2021-01-21 13:58:55 -05:00
Ridhwana
2dad0c42f8
Save Data Update Script errors to database and show them on http://localhost:3000/admin/data_update_scripts (#12348)
* feat: add an error column to the data update script

* feat: save the error to the error field

* feat: save the error when the script fails

* feat: show the script error on the data update script page

* chore: pass the error to mark_as_failed instead of having its own function

* refactor: use presence

* test: ensure that we test an error case of a data update script

* chore: rename errorneous to failing

* test: update some specs, working on the others

* chore: update tests now that there are two files

* chore: change error from a string to a text to allow for more char
2021-01-21 14:48:34 +01:00
Michael Kohl
71ea85be6e
Verify current password on password change (#12174)
* Verify current password on password change

* Address PR comments

* Allow password reset for logged in users

* Make password change message more explicit

* Reformat message

* Fix specs
2021-01-21 12:40:54 +07:00
Ben Halpern
e3d39e09b4
Patch: Fix UI bugs in follow adjustment form (#12137)
* Fix UI bugs in follow adjustment form

* Move to bottom
2021-01-20 17:23:18 -05:00
Michael Kohl
5d0fe12528
Update NavigationLink handling (#12316)
* Update copy

* Allow relative URLs and normalize on save

* Update specs

* Move clarification from index to form

* Add data update script

* Update spec
2021-01-20 13:57:59 -05:00
Arit Amana
94236d7ee6
Update dev.to/mods for non-logged in users (#12301)
* complete implementation

* check if forem is DEV properly

* Add tests

* improve tests

* improve tests again

* REALLY improve tests (sheesh!)

* Address code review comments

* small changes

* modify specs
2021-01-20 13:53:50 -05:00
Andy Zhao
0f15b8dbd3
Don't try to unsub users when destroying if Mailchimp is not enabled (#12331)
* Use proper Mailchimp newsletter IDs respective to methods

* Add guard clauses when Mailchimp newsletter isn't enabled

* Rubocop correction

* Only unsub after destroy if Mailchimp newsletter is enabled

* Refactor a bit

* Fix typo

* Fix boolean logic for guard clauses

* Update tests to account for new SiteConfig logic

* Break guard clause into two clauses
2021-01-20 12:32:35 -05:00
Alex
f5ab9552d5
Move MarkdownTraverser to service (#12282) 2021-01-20 11:29:42 -05:00
Mac Siri
bdd05f7a9d
Reindex comments' Elasticsearch doc when commentable is updated (#12330) 2021-01-20 09:44:59 -05:00
Suzanne Aitchison
a5365b762e
add permalinks to editor guide headings (#12347) 2021-01-20 14:39:05 +00:00
Dany Marcoux
4022ea9fc0
Fix deprecation warnings (#12339)
* Fix deprecation warnings in Images::Optimizer

The deprecation warnings were:

warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `cloudinary' is defined here

and

warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `imgproxy' is defined here

* Fix deprecation warning in Slack::Messengers::ArticlePublished

The deprecation warning was:

warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `initialize' is defined here
2021-01-20 10:01:20 +01:00
Andy Zhao
8d462801ec
Add new cache key for article sidebar & bottom_content (#12185)
* Add new cache key for article sidebar & bottom_content

* Trigger build

* Undo automatic changes from 'merge conflict fixes' commit

* Revert to actual previous version, oops

* Trying again...

* Trying again...

* Trying again...

* Remove unnecessary variable

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-01-19 14:03:15 -05:00
Anna Buianova
5b7a3df004 Load campaign articles in a widget as a collection (#12334) 2021-01-19 20:33:39 +03:00
Nick Taylor
86eb75cee7
Report a Message in Connect (#12229)
* 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>
2021-01-19 12:07:47 -05:00
Ben Halpern
ed04875074
Fix image assets in tweets and remove like/retweet counts (#12327) 2021-01-19 10:30:38 -05:00
Jacob Herrington
db335ff84b
Display message from the back end when leaving a channel (#11711)
* Display message from the back end when leaving a channel

Co-authored-by: jacobherrington <jacobherringtondeveloper@gmail.com>
Co-authored-by: Alberto Pérez de Rada Fiol <apdrf.94@gmail.com>
Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-01-19 09:06:47 -06:00
leewynne
58efe300ac
generalise sidebar campaign published article timeframe (#12278) 2021-01-19 08:40:39 -06:00
Philip Q Nguyen
fe00bcacf9
BUGFIX: Allow image upload even if no existing image (#12312)
* Allow image upload even if no existing image

Allow profile image upload even if there's no profile image attached.

* Add specs to ensure profile image field is there

Specs to ensure that the profile image upload field is always
available wether the user has a profile picture or not.
2021-01-19 11:47:09 +01:00
Suzanne Aitchison
516bab133f
Storybook dropdown should be accessible 11724 (#12295)
* allow keyboard access to dropdown stories

* add accessibility notes to dropdown stories

* manage focus in html example

* Update reference to aria attributes in notes

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* add focus style to link for keyboard users

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-01-19 08:51:37 +00:00
Ben Halpern
d7732499b9
Improve cumulative layout shift on comment reactions + optimizations (#12309)
* Improve content layout shift on comment reactions + optimizations

* Clean ups, tests, and docs

* Fix test typo

* Update app/views/comments/_comment_footer.html.erb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update docs/technical-overview/architecture.md

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Update docs/technical-overview/architecture.md

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Update docs/technical-overview/architecture.md

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Refactor and add jsdoc

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-01-18 19:29:44 -05:00
le-hu
619dd813c7
secure Identity#email in case of missing auth_data_dump hash (#11936) (#12322)
* secure Identity#email in case of missing auth_data_dump hash (#11936)

* Refactor Identity#email

* Delete wrongly commited debugging line

* extract no email found message into Const

* refactor Identity#email to use || as flow control
2021-01-18 19:27:07 -05:00
Nick Taylor
425c3072f7
Fix broken test pre-Preact upgrade (#12328)
* Removed import of xss as it already happens in testSetup.js

* Fixed invalid setting for a the children prop.
2021-01-18 14:39:17 -05:00
Ben Halpern
472c3d2922
Fix and refactor hide user content (#12307) 2021-01-18 11:08:23 -05:00
Shilpi Agrawal
92f191445b
Refactored all site config default hardcoded value in rspec test (#12315)
* Refactored all site config default hardcoded value in rspec test

* Remove Liquid::BlockBody patch (#12313)

* Refactored all site config default hardcoded value in rspec test

* Added seperate function to fetch default site confif value and using it in specs

Co-authored-by: rhymes <rhymes@hey.com>
2021-01-18 15:23:40 +01:00
Anna Buianova
020912264e
Optimize loading partials as collections (#12276)
* Load events' partials  as collections

* Load /admin/articles partials as collections

* Render sponsorships partial as collection

* Render organization articles partials as collection

* Load users articles partials as collections
2021-01-18 14:18:33 +03:00
dependabot[bot]
a63ba17b6a
Bump liquid from 4.0.3 to 5.0.0 (#12150)
* Bump liquid from 4.0.3 to 5.0.0

Bumps [liquid](https://github.com/Shopify/liquid) from 4.0.3 to 5.0.0.
- [Release notes](https://github.com/Shopify/liquid/releases)
- [Changelog](https://github.com/Shopify/liquid/blob/master/History.md)
- [Commits](https://github.com/Shopify/liquid/compare/v4.0.3...v5.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Convert ActiveSupport::SafeBuffer to string

* Disable echo and render tags

* Disable liquid tag

* Add issue link

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rhymes <rhymes@hey.com>
2021-01-15 15:37:42 -06:00
Bogdan Covrig
ad4df246dd
Replace misc :user_settings_path with :customization (#12300) 2021-01-15 15:17:23 -06:00
Julianna Tetreault
d06ee645f8
Improve Error Messaging for Self-Deletion Confirmation Flow (#12266) [deploy]
* 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
2021-01-15 11:51:06 -07:00
Fernando Valverde
e60159184f
Fixes apple auth creator flow in /admin/config (#12287) 2021-01-15 08:07:34 -06:00
Molly Struve
636f4b0ae1
Bug Fix:Increase Default Rate Limit for User Updates to 15 (#12281)
* Bug Fix:Increase Default Rate Limit for User Updates to 15

* spec fix
2021-01-14 12:51:08 -06:00
Ben Halpern
4c6a7ef234
Fix outstanding /pod main image problem (#12280) 2021-01-14 13:18:47 -05:00
Fernando Valverde
7f3859a8b4
Workaround for Apple auth problems (still in beta) (#12263)
* Workaround for Apple auth problems (still in beta)

* Fix spec
2021-01-14 09:44:56 -06:00
Ben Halpern
444841bb90
Fix domain list bug (#12268) 2021-01-14 10:43:42 -05:00
Alex
31689fd76a
Break MarkdownFixer into MarkdownProcessor::Fixer services (#12241)
* 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
2021-01-14 10:26:46 -05:00
Michael Kohl
cc6edc66b6
Remove contact_consent column from ignore list (#12254) 2021-01-14 12:38:42 +07:00
Molly Struve
5a3ea304ca
Log User Save Error Messages When it Fails (#12267) 2021-01-13 16:14:48 -06:00
Andy Zhao
eed4df0fa4
Add sorting feature to /admin/tags (#12249)
* 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
2021-01-13 17:03:17 -05:00
Andy Zhao
b45c578ea1
Encode emails properly before sending to /confirm-email (#12211)
* 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)
2021-01-13 15:17:14 -05:00