pinchflat/test/support/fixtures/sources_fixtures.ex
Kieran dc0313d875
Fast indexing (#58)
* Made method to getting singular media details; Renamed other related method

* Takes a fun and flirty digression to remove abstractions around yt-dlp since I'm 100% committed to using it exclusively

* Removed commented test code

* Lays the groundwork for fast indexing

* Added module for working with youtube RSS feed

* Added methods to kick off indexing workers from RSS response

* Improve short detection (#59)

* Made media attribute-related yt-dlp calls return a struct

* Added shorts attribute to media items

* Added ability to discern a short from yt-dlp response

* Updated search to use new shorts attribute

* Fast index UI (#63)

* Added fast_index field and adds it to source form

* Added fast indexing to source changeset operations

* Added fast indexing worker and updated other modules to start using it

* Handled fast index worker on source update

* Add support modals (#65)

* Added fast indexing upgrade modal

* Improved modal on smaller screens

* Updated links to work again

* Added donation modal

* Reverted source fast index to 15 minutes

* Removed unneeded HTML attributes from old alpine approach
2024-03-10 14:36:34 -07:00

67 lines
1.7 KiB
Elixir

defmodule Pinchflat.SourcesFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Pinchflat.Sources` context.
"""
alias Pinchflat.Repo
alias Pinchflat.ProfilesFixtures
alias Pinchflat.Sources.Source
@doc """
Generate a source.
"""
def source_fixture(attrs \\ %{}) do
{:ok, source} =
%Source{}
|> Source.changeset(
Enum.into(attrs, %{
collection_name: "Source ##{:rand.uniform(1_000_000)}",
collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")),
collection_type: "channel",
custom_name: "Cool and good internal name!",
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
media_profile_id: ProfilesFixtures.media_profile_fixture().id,
index_frequency_minutes: 60
})
)
|> Repo.insert()
source
end
def source_attributes_return_fixture do
source_attributes = [
%{
id: "video1",
title: "Video 1",
webpage_url: "https://example.com/video1",
was_live: false,
description: "desc1",
aspect_ratio: 1.67,
duration: 12.34
},
%{
id: "video2",
title: "Video 2",
webpage_url: "https://example.com/video2",
was_live: true,
description: "desc2",
aspect_ratio: 1.67,
duration: 345.67
},
%{
id: "video3",
title: "Video 3",
webpage_url: "https://example.com/video3",
was_live: false,
description: "desc3",
aspect_ratio: 1.0,
duration: 678.90
}
]
source_attributes
|> Enum.map_join("\n", &Phoenix.json_library().encode!(&1))
end
end