Use explicit points for following and hidden tags (#20032)

This commit is contained in:
Ridhwana 2023-09-05 19:17:27 +02:00 committed by GitHub
parent 49a45f0618
commit a6d8767aaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -172,11 +172,12 @@ class Tag < ActsAsTaggableOn::Tag
# returns the tags that are followed by the user
# @param user [User] the user to check
# @param points [Range] the range of points to check for (default is 0 (including 0) to infinity)
# @param points [Range] the range of explicit points to check for (default is 0 (including 0) to infinity)
# @return [ActiveRecord::Relation<Tag>] the tags followed by the user
def self.followed_by(user, points = (0...))
def self.followed_by(user, explicit_points = (0...))
joins("INNER JOIN follows ON tags.id = follows.followable_id")
.where(follows: { follower_id: user.id, followable_type: "ActsAsTaggableOn::Tag", points: points })
.where(follows: { follower_id: user.id, followable_type: "ActsAsTaggableOn::Tag",
explicit_points: explicit_points })
.order("follows.points DESC")
end

View file

@ -228,7 +228,7 @@ RSpec.describe Tag do
second_followed.update explicit_points: 0
antifollowed = user.follow(antifollowed_tag)
antifollowed.update explicit_points: -5
antifollowed.update(explicit_points: -5, implicit_points: 6)
other.follow(other_followed_tag)
end