From a6d8767aaaa6af85a3ce4e86763a6dabc7e40a04 Mon Sep 17 00:00:00 2001 From: Ridhwana Date: Tue, 5 Sep 2023 19:17:27 +0200 Subject: [PATCH] Use explicit points for following and hidden tags (#20032) --- app/models/tag.rb | 7 ++++--- spec/models/tag_spec.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index 4c9e476af..ec9072d1e 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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] 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 diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 0962c4b5c..560800415 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -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