Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
1.8 KiB
Ruby
57 lines
1.8 KiB
Ruby
def seed_plan!(slug, name, features, stripe_price_id: nil)
|
|
plan = Plan.find_or_initialize_by(slug: slug)
|
|
plan.name = name
|
|
plan.features = features
|
|
plan.stripe_price_id = stripe_price_id if stripe_price_id.present?
|
|
plan.save!
|
|
end
|
|
|
|
legacy = Plan.find_by(slug: "premium")
|
|
if legacy && !Plan.exists?(slug: "premium_full")
|
|
legacy.update!(slug: "premium_full", name: "Premium Full")
|
|
end
|
|
|
|
seed_plan!("free", "Free", {
|
|
"max_staff_transmission" => 1,
|
|
"max_staff_regia" => 1,
|
|
"concurrent_streams_limit" => 1,
|
|
"platforms" => %w[matchlivetv],
|
|
"recordings_enabled" => false,
|
|
"recording_days" => 0,
|
|
"phone_download_enabled" => false,
|
|
"youtube_enabled" => false,
|
|
"youtube_mode" => nil
|
|
})
|
|
|
|
seed_plan!("premium_light", "Premium Light", {
|
|
"max_staff_transmission" => 5,
|
|
"max_staff_regia" => 5,
|
|
"concurrent_streams_limit" => 3,
|
|
"platforms" => %w[matchlivetv],
|
|
"recordings_enabled" => true,
|
|
"recording_days" => 30,
|
|
"phone_download_enabled" => true,
|
|
"youtube_enabled" => true,
|
|
"youtube_mode" => "matchlivetv_light"
|
|
}, stripe_price_id: ENV["STRIPE_PREMIUM_LIGHT_PRICE_ID"].presence)
|
|
|
|
seed_plan!("premium_full", "Premium Full", {
|
|
"max_staff_transmission" => nil,
|
|
"max_staff_regia" => nil,
|
|
"concurrent_streams_limit" => 10,
|
|
"platforms" => %w[matchlivetv youtube facebook twitch],
|
|
"recordings_enabled" => true,
|
|
"recording_days" => 90,
|
|
"phone_download_enabled" => true,
|
|
"youtube_enabled" => true,
|
|
"youtube_mode" => "team"
|
|
}, stripe_price_id: ENV["STRIPE_PREMIUM_FULL_PRICE_ID"].presence || ENV["STRIPE_PREMIUM_PRICE_ID"].presence)
|
|
|
|
Subscription.joins(:plan).where(plans: { slug: "premium_full" }).find_each do |sub|
|
|
next if sub.plan.slug == "premium_full"
|
|
|
|
sub.update!(plan: Plan["premium_full"])
|
|
end
|
|
|
|
puts "Plans: #{Plan.pluck(:slug).join(', ')}"
|