Skip to content

Commit

Permalink
fix: Increate max video length + truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Nov 9, 2024
1 parent 0c907d9 commit 0b376a6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/db/lib/db_schema/video.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,24 @@ defmodule DB.Schema.Video do
|> cast(params, [:url, :title, :language])
|> validate_required([:url, :title])
|> parse_video_url()
|> validate_length(:title, min: 5, max: 120)
|> update_change(:title, &truncate_title/1)
|> validate_length(:title, min: 5, max: 130)
|> unique_constraint(:videos_youtube_id_index)
|> unique_constraint(:videos_facebook_id_index)
# Change locales like "en-US" to "en"
|> update_change(:language, &format_language/1)
end


defp truncate_title(title) do
trimmed = String.trim(title)
if String.length(trimmed) > 130 do
String.slice(trimmed, 0..128) <> "…"
else
trimmed
end
end

defp format_language("zxx"), do: nil

defp format_language(locale) do
Expand Down

0 comments on commit 0b376a6

Please sign in to comment.