-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Remove special case notifying author of threads #1037
base: develop
Are you sure you want to change the base?
Conversation
Instead of special casing creating a notification, we just have them follow normally automatically.
By the way (I forgot to mention), this does mean that everyone will no longer be following new threads on their posts since this change isn't retroactive. They'd have to actually click the follow new threads button on their posts. Someone could presumably make a one-off migration script somewhere to fix this, I'm not confident enough to do so myself. |
Oh, that would be bad; we don't want to quietly cancel notifications on older posts. I don't know how to write the migration script either, but the other way to do it would be to keep the extra check until we do -- so do make the change where we implement notifications as auto-follows on new posts, but in the code that decides whether to notify, keep the check for "is my post" along with "is followed" until we can fix existing follows. |
Problems discovered during testingI also don't know how to write the database script, but happy to work together on learning how once we know what we're aiming for. Before that, I've found some odd behaviour. I've tested on this new branch and also on I checked the contents of the Summary of the problems
Tests on
|
Sorry it took so long to address those issues! Life (and accidental database corruption) got in the way. The last commit should fix them (apparently there comment following logic is spread out over all three of Test 1
Test 3
Test 2
Test 4
|
Thanks for fixing all the problems! Please don't apologise for life getting in the way - life comes first. I'm not just saying that because of being distracted myself recently - it's my view in general. I don't have access to approve pull requests but it's looking good to me. Is the database script you mentioned previously the only thing remaining now? I'm guessing it would need to do the following:
It looks like there are some one-off scripts in |
We could set this up on the dev server for testing when the DB-update stuff is ready. |
@MoshiKoi So users need to follow their own posts now, that would be Then modify this file and change the change method as follows: def change
to_insert = Post.where.not(post_type_id: [PolicyDoc.post_type_id, HelpDoc.post_type_id])
.where.not(user_id: nil)
.pluck(:id, :user_id)
.map { |post_id, user_id| { post_id: post_id, user_id: user_id } }
ThreadFollower.insert_all(to_insert)
end This will transform each post into an entry SELECT id, user_id FROM posts WHERE post_type_id IN (?, ?) AND user_id IS NOT NULL;
INSERT INTO thread_followers (post_id, user_id, created_at, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP()), (?, ?, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP()), ... In rails, it avoids constructing all the post objects, instead constructing only an array of the ids and user ids, which is then transformed into an array of hashes to be able to be passed to insert_all. |
Instead of special casing creating a notification, we just have them follow normally automatically. Resolves #1025