-
-
Notifications
You must be signed in to change notification settings - Fork 71
Follow / unfollow thread actions should bump its last activity date & time + minor general fixes #1931
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
Merged
Merged
Follow / unfollow thread actions should bump its last activity date & time + minor general fixes #1931
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a994cf8
switched comments last_activity_at to a column
Oaphi 940aaa1
switched comment threads last_activity_at to a column
Oaphi 0594fdd
added last_activity wrapper method to Comment (max of created, update…
Oaphi 253a35b
renamed last_activity_at CommentThread method to last_activity & ensu…
Oaphi 178e300
made bump_last_activity_at methods public to be able to bump by unrel…
Oaphi cbde601
switched 'thread_content' freshness check to last_activity & added th…
Oaphi 3f1b69e
creating/destroying ThreadFollowers should bump their threads last ac…
Oaphi dff7c9f
renamed all *_last_activity_at methods to *_last_activity
Oaphi 66e035e
[unrelated] fixed test description for the pings method
Oaphi c73eb26
[unrelated] fixed User#anonymize confusing inverted persist_changes p…
Oaphi c12ef0c
added tests for Comment#last_activity method
Oaphi bbf383a
reworked CommentThread#last_activity_at test into the new CommentThre…
Oaphi aa48e58
added CommentThread#add_follower QoL method & expanded last_activity …
Oaphi 0f32bf4
added CommentThread#remove_follower QoL method & expanded last_activi…
Oaphi be1f952
CommentThread#bump_last_activity should have the option to persist ch…
Oaphi 18142a4
Comment#bump_last_activity should have the option to persist changes
Oaphi 74eaa4c
CommentThread#remove_follower should remove all followers
Oaphi d06c750
add_follower should prevent duplicate thread follower records
Oaphi a4d6b95
moved unfollowing coment threads from unrestrict_thread to its own un…
Oaphi 8f5b894
let's not fail if add_follower / remove_follower is a noop
Oaphi 76f5655
added job for cleaning up duplicate thread followers
Oaphi b6d0a52
even if there's nothing to do, bump thread's last activity to improve…
Oaphi d2f2a81
added tests covering CommentThread#remove_follower last activity bumping
Oaphi 8a6e63b
thread wrapper can be absent at the time of handling follow/unfollow …
Oaphi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| class CleanUpThreadFollowersJob < ApplicationJob | ||
| queue_as :default | ||
|
|
||
| def perform | ||
| sql = File.read(Rails.root.join('db/scripts/threads_with_duplicate_followers.sql')) | ||
| threads = ActiveRecord::Base.connection.execute(sql).to_a | ||
|
|
||
| threads.each do |thread| | ||
| user_id, thread_id = thread | ||
|
|
||
| followers = ThreadFollower.where(comment_thread_id: thread_id, user_id: user_id) | ||
|
|
||
| next unless followers.many? | ||
|
|
||
| duplicate = followers.first | ||
| result = duplicate.destroy | ||
|
|
||
| unless result | ||
| puts "failed to destroy thread follower duplicate \"#{duplicate.id}\"" | ||
| duplicate.errors.each { |e| puts e.full_message } | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20251221140930_add_last_activity_at_to_comments.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class AddLastActivityAtToComments < ActiveRecord::Migration[7.2] | ||
| def change | ||
| add_column :comments, :last_activity_at, :datetime | ||
| end | ||
| end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20251221142105_add_last_activity_at_to_comment_threads.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class AddLastActivityAtToCommentThreads < ActiveRecord::Migration[7.2] | ||
| def change | ||
| add_column :comment_threads, :last_activity_at, :datetime | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| select | ||
| user_id, | ||
| comment_thread_id, | ||
| count(*) as count | ||
| from | ||
| thread_followers | ||
| where | ||
| post_id is null | ||
| group by | ||
| user_id, | ||
| comment_thread_id | ||
| having | ||
| count > 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CleanUpThreadFollowersJob.perform_later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.