Added shorts attribute to media items
This commit is contained in:
parent
5e8689836d
commit
f50bcb24bf
4 changed files with 16 additions and 11 deletions
|
|
@ -189,16 +189,9 @@ defmodule Pinchflat.Media do
|
|||
Returns {:ok, %MediaItem{}} | {:error, %Ecto.Changeset{}}
|
||||
"""
|
||||
def create_media_item_from_backend_attrs(source, media_attrs_struct) do
|
||||
attrs = %{
|
||||
source_id: source.id,
|
||||
title: media_attrs_struct.title,
|
||||
media_id: media_attrs_struct.media_id,
|
||||
original_url: media_attrs_struct.original_url,
|
||||
livestream: media_attrs_struct.livestream,
|
||||
description: media_attrs_struct.description
|
||||
}
|
||||
|
||||
create_media_item(attrs)
|
||||
%{source_id: source.id}
|
||||
|> Map.merge(Map.from_struct(media_attrs_struct))
|
||||
|> create_media_item()
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ defmodule Pinchflat.Media.MediaItem do
|
|||
:original_url,
|
||||
:livestream,
|
||||
:source_id,
|
||||
:short_form_content,
|
||||
# these fields are captured only on download
|
||||
:media_downloaded_at,
|
||||
:media_filepath,
|
||||
|
|
@ -27,7 +28,7 @@ defmodule Pinchflat.Media.MediaItem do
|
|||
:thumbnail_filepath,
|
||||
:metadata_filepath
|
||||
]
|
||||
@required_fields ~w(title original_url livestream media_id source_id)a
|
||||
@required_fields ~w(title original_url livestream media_id source_id short_form_content)a
|
||||
|
||||
schema "media_items" do
|
||||
field :title, :string
|
||||
|
|
@ -35,6 +36,7 @@ defmodule Pinchflat.Media.MediaItem do
|
|||
field :description, :string
|
||||
field :original_url, :string
|
||||
field :livestream, :boolean, default: false
|
||||
field :short_form_content, :boolean, default: false
|
||||
field :media_downloaded_at, :utc_datetime
|
||||
|
||||
field :media_filepath, :string
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Pinchflat.Repo.Migrations.AddShortFormToMediaItems do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:media_items) do
|
||||
add :short_form_content, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -19,6 +19,7 @@ defmodule Pinchflat.MediaFixtures do
|
|||
title: Faker.Commerce.product_name(),
|
||||
original_url: "https://www.youtube.com/watch?v=#{media_id}",
|
||||
livestream: false,
|
||||
short_form_content: false,
|
||||
media_filepath: "/video/#{Faker.File.file_name(:video)}",
|
||||
source_id: SourcesFixtures.source_fixture().id
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue