mirror of
https://github.com/discourse/discourse.git
synced 2025-09-12 21:10:47 +08:00
PERF: shift most user options out of the user table
As it stands we load up user records quite frequently on the topic pages, this in turn pulls all the columns for the users being selected, just to discard them after they are loaded New structure keeps all options in a discrete table, this is better organised and allows us to easily add more column without worrying about bloating the user table
This commit is contained in:
parent
63cda22623
commit
3829c78526
28 changed files with 363 additions and 191 deletions
|
@ -55,7 +55,8 @@ describe Jobs::UserEmail do
|
|||
end
|
||||
|
||||
it "does send an email to a user that's been recently seen but has email_always set" do
|
||||
user.update_attributes(last_seen_at: 9.minutes.ago, email_always: true)
|
||||
user.update_attributes(last_seen_at: 9.minutes.ago)
|
||||
user.user_option.update_attributes(email_always: true)
|
||||
Email::Sender.any_instance.expects(:send)
|
||||
Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)
|
||||
end
|
||||
|
@ -188,13 +189,13 @@ describe Jobs::UserEmail do
|
|||
it "does send the email if the notification has been seen but the user is set for email_always" do
|
||||
Email::Sender.any_instance.expects(:send)
|
||||
notification.update_column(:read, true)
|
||||
user.update_column(:email_always, true)
|
||||
user.user_option.update_column(:email_always, true)
|
||||
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id)
|
||||
end
|
||||
|
||||
it "doesn't send the mail if the user is using mailing list mode" do
|
||||
Email::Sender.any_instance.expects(:send).never
|
||||
user.update_column(:mailing_list_mode, true)
|
||||
user.user_option.update_column(:mailing_list_mode, true)
|
||||
# sometimes, we pass the notification_id
|
||||
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
||||
# other times, we only pass the type of notification
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue