diff --git a/lib/live_beats/media_library.ex b/lib/live_beats/media_library.ex index 8de4e0f..2d28dbf 100644 --- a/lib/live_beats/media_library.ex +++ b/lib/live_beats/media_library.ex @@ -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 diff --git a/lib/live_beats/media_library/song.ex b/lib/live_beats/media_library/song.ex index 76b8af6..c61810a 100644 --- a/lib/live_beats/media_library/song.ex +++ b/lib/live_beats/media_library/song.ex @@ -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 diff --git a/lib/live_beats_web/live/profile_live.ex b/lib/live_beats_web/live/profile_live.ex index cbadb1b..15713fc 100644 --- a/lib/live_beats_web/live/profile_live.ex +++ b/lib/live_beats_web/live/profile_live.ex @@ -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) diff --git a/lib/live_beats_web/live/profile_live/upload_form_component.html.heex b/lib/live_beats_web/live/profile_live/upload_form_component.html.heex index 3bb3d48..5b0cd2f 100644 --- a/lib/live_beats_web/live/profile_live/upload_form_component.html.heex +++ b/lib/live_beats_web/live/profile_live/upload_form_component.html.heex @@ -2,6 +2,7 @@

(songs expire every six hours)

<.form + for={%{}} as={:songs} id="song-form" class="space-y-8" diff --git a/priv/repo/migrations/20230308164408_add_speech_segments_to_songs.exs b/priv/repo/migrations/20230308164408_add_speech_segments_to_songs.exs new file mode 100644 index 0000000..503d726 --- /dev/null +++ b/priv/repo/migrations/20230308164408_add_speech_segments_to_songs.exs @@ -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 diff --git a/priv/repo/migrations/20230308164408_add_text_segments_to_songs.exs b/priv/repo/migrations/20230308164408_add_text_segments_to_songs.exs deleted file mode 100644 index bdc1193..0000000 --- a/priv/repo/migrations/20230308164408_add_text_segments_to_songs.exs +++ /dev/null @@ -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