Skip to content

Commit

Permalink
Fix: Hide private charts in variants
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi authored Jan 23, 2024
1 parent 8e8ddd5 commit 249652b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/app/models/chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Chart < ApplicationRecord
}

has_many :file_resources, dependent: :destroy
has_many :variants,
has_many :_variants,
class_name: "Chart",
foreign_key: "variant_id",
dependent: :nullify,
Expand All @@ -23,7 +23,7 @@ class Chart < ApplicationRecord
class_name: "Chart",
optional: true,
foreign_key: "variant_id",
inverse_of: :variants
inverse_of: :_variants
has_many :likes, dependent: :destroy
has_many :tags, dependent: :destroy
enum chart_type: { sus: 0, mmws: 1, chs: 2, usc: 3 }
Expand All @@ -50,6 +50,10 @@ def resources
background_v1: base.find(&:background_v1?)
}
end

def variants(include_private: false)
_variants.filter(&visibility_public?)
end

def to_frontend(user: nil, with_resources: true, with_variants: true)
resources = with_resources ? self.resources : {}
Expand Down

0 comments on commit 249652b

Please sign in to comment.