-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEV: Redesign chat mentions #24752
DEV: Redesign chat mentions #24752
Conversation
b2cb27f
to
2887a5e
Compare
7c338d0
to
1c8f343
Compare
ad23354
to
d9ba3a7
Compare
e839fb4
to
542a1b0
Compare
fa0534e
to
a06deea
Compare
plugins/chat/db/post_migrate/20231227160005_make_type_on_chat_mentions_non_nullable.rb
Outdated
Show resolved
Hide resolved
cc139ae
to
aef0bfd
Compare
@jjaffeux, I've rebased the branch and also fixed test failures (the most of them were because of a typo). I've also addressed your recent comment regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, didn't retry it locally this time, but it seems fine and not much has changed anyways. 🚀
fccece3
to
c687487
Compare
rather than calling an overarching service that does other stuff
… true when altering indexes
With the previous condition we risked to accidentally corrupt here and all mentions, since they don't have target_id
c687487
to
87e8de1
Compare
target_id = user_id | ||
elsif mention_klass == ::Chat::GroupMention | ||
begin | ||
target_id = Group.where("LOWER(name) = ?", "#{mention_type}").first.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: if you only care about some fields about 1 record, you can use #pick
and list the fields you want.
This avoids loading the whole record in memory (due to the .first
) when we only want the id
.
target_id = Group.where("LOWER(name) = ?", "#{mention_type}").first.id | |
target_id = Group.where("LOWER(name) = ?", "#{mention_type}").pick(:id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, merged the PR before I saw this. I've fixed it in a follow-up – #25301.
This pull request has been mentioned on Discourse Meta. There might be relevant details there: https://meta.discourse.org/t/query-causing-400-cpu-load/285542/27 |
At the moment, when someone is mentioning a group, or using
here
orall
mention, we create achat_mention
record per user. What we want instead is to have special kinds of mentions, so we can create only onechat_mention
record in such cases. This PR implements that.Note, that such mentions will still have N related notifications, one notification per a user. We don't expect we'll have performance problems on the notifications side, but if at some point we do, we should be able to solve them on the side of notifications (notifications are handled in jobs, also some little delays with the notifications are acceptable, so we can make sure notifications are properly queued, and that processing of every notification is fast enough to make delays small enough).
The preparation work for this PR was done in fbd24fa, where we make it possible for one mention to have several related notifications.
A pretty tricky part of this PR is schema and data migration, I've explained related details inline on the migration files.