This commit is contained in:
Chris McCord 2023-03-09 09:34:43 -05:00
parent a1c6c454f0
commit 6c13ad3b9b
6 changed files with 16 additions and 15 deletions

View file

@ -218,7 +218,7 @@ defmodule LiveBeats.MediaLibrary do
segment
end)
insert_text_segments(song, segments)
insert_speech_segments(song, segments)
end)
{ref, song}
@ -240,8 +240,8 @@ defmodule LiveBeats.MediaLibrary do
end
end
defp insert_text_segments(song, segments) do
Repo.update_all(from(s in Song, where: s.id == ^song.id), set: [text_segments: segments])
defp insert_speech_segments(song, segments) do
Repo.update_all(from(s in Song, where: s.id == ^song.id), set: [speech_segments: segments])
end
defp broadcast_imported(%Accounts.User{} = user, songs) do

View file

@ -24,7 +24,7 @@ defmodule LiveBeats.MediaLibrary.Song do
field :position, :integer, default: 0
belongs_to :user, Accounts.User
belongs_to :genre, LiveBeats.MediaLibrary.Genre
embeds_many :text_segments, LiveBeats.MediaLibrary.TextSegment
embeds_many :speech_segments, LiveBeats.MediaLibrary.TextSegment
timestamps()
end

View file

@ -164,7 +164,7 @@ defmodule LiveBeatsWeb.ProfileLive do
end
active_song = MediaLibrary.get_current_active_song(profile)
speech_segments = if active_song, do: active_song.text_segments, else: []
speech_segments = if active_song, do: active_song.speech_segments, else: []
songs = MediaLibrary.list_profile_songs(profile, 50)
@ -344,7 +344,7 @@ defmodule LiveBeatsWeb.ProfileLive do
stream_insert(socket, :songs, %MediaLibrary.Song{song | status: :playing})
active_song_id ->
Enum.reduce(song.text_segments, socket, fn seg, acc ->
Enum.reduce(song.speech_segments, socket, fn seg, acc ->
stream_insert(acc, :speech_segments, seg)
end)
|> stop_song(active_song_id)

View file

@ -2,6 +2,7 @@
<p class="inline text-gray-500 text-sm">(songs expire every six hours)</p>
<.form
for={%{}}
as={:songs}
id="song-form"
class="space-y-8"

View file

@ -0,0 +1,9 @@
defmodule LiveBeats.Repo.Migrations.AddSpeechSegmentsToSongs do
use Ecto.Migration
def change do
alter table(:songs) do
add :speech_segments, {:array, :map}, null: false, default: []
end
end
end

View file

@ -1,9 +0,0 @@
defmodule LiveBeats.Repo.Migrations.AddLyricsToSongs do
use Ecto.Migration
def change do
alter table(:songs) do
add :text_segments, {:array, :map}, null: false, default: []
end
end
end