Aggiunge modulo Replay, Garage dev e YouTube a livello società.

Pipeline registrazione/upload con storage S3, archivio web e app, proxy replay
per il browser, OAuth YouTube sulla pagina club (Premium Full) e footer legale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 07:53:11 +02:00
parent a87cda156b
commit 1f273f849d
87 changed files with 2952 additions and 195 deletions

View File

@@ -0,0 +1,21 @@
class EnhanceRecordingsForReplayModule < ActiveRecord::Migration[7.2]
def change
change_table :recordings, bulk: true do |t|
t.string :title
t.string :privacy_status, null: false, default: "unlisted"
t.bigint :byte_size
t.integer :duration_secs
t.string :storage_key
t.string :storage_bucket
t.string :storage_backend, null: false, default: "local"
t.datetime :recorded_at
t.datetime :deleted_at
t.text :error_message
end
add_index :recordings, :privacy_status
add_index :recordings, :deleted_at
add_index :recordings, %i[team_id status]
add_index :recordings, :storage_key, unique: true, where: "storage_key IS NOT NULL"
end
end

View File

@@ -0,0 +1,16 @@
class ReplayEnhancements < ActiveRecord::Migration[7.2]
def change
change_table :recordings, bulk: true do |t|
t.jsonb :metadata, null: false, default: {}
t.string :thumbnail_storage_key
t.integer :view_count, null: false, default: 0
t.datetime :ready_notified_at
t.datetime :expiry_warning_sent_at
t.string :youtube_video_id
t.datetime :youtube_published_at
end
add_index :recordings, :view_count
add_index :recordings, :youtube_video_id, where: "youtube_video_id IS NOT NULL"
end
end

View File

@@ -0,0 +1,57 @@
# frozen_string_literal: true
class MoveYoutubeCredentialsToClubs < ActiveRecord::Migration[7.2]
def up
unless column_exists?(:youtube_credentials, :club_id)
add_reference :youtube_credentials, :club, type: :uuid, foreign_key: true
end
if column_exists?(:youtube_credentials, :team_id)
say_with_time "Associa credenziali YouTube alle società" do
execute <<~SQL.squish
UPDATE youtube_credentials yc
SET club_id = t.club_id
FROM teams t
WHERE t.id = yc.team_id AND yc.club_id IS NULL
SQL
end
execute <<~SQL.squish
DELETE FROM youtube_credentials yc
USING youtube_credentials newer
WHERE yc.club_id = newer.club_id
AND yc.id <> newer.id
AND yc.updated_at < newer.updated_at
SQL
change_column_null :youtube_credentials, :club_id, false
remove_index :youtube_credentials, :team_id, if_exists: true
remove_reference :youtube_credentials, :team, foreign_key: true
end
unless index_exists?(:youtube_credentials, :club_id)
add_index :youtube_credentials, :club_id, unique: true
end
end
def down
return unless column_exists?(:youtube_credentials, :club_id)
add_reference :youtube_credentials, :team, type: :uuid, foreign_key: true unless column_exists?(:youtube_credentials, :team_id)
execute <<~SQL.squish
UPDATE youtube_credentials yc
SET team_id = (
SELECT t.id FROM teams t
WHERE t.club_id = yc.club_id
ORDER BY t.created_at
LIMIT 1
)
SQL
change_column_null :youtube_credentials, :team_id, false
remove_index :youtube_credentials, :club_id, if_exists: true
remove_reference :youtube_credentials, :club, foreign_key: true
add_index :youtube_credentials, :team_id, if_not_exists: true
end
end