Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update player to use bucket from feed instead of env #620

Merged
merged 9 commits into from
Sep 10, 2024
Merged
2 changes: 1 addition & 1 deletion server/lib/orcasite/radio/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Orcasite.Radio.Feed do
attribute :intro_html, :string, default: "", public?: true
attribute :image_url, :string, default: "", public?: true
attribute :visible, :boolean, default: true, public?: true
attribute :bucket, :string, public?: true
attribute :bucket, :string, public?: true, allow_nil?: false
attribute :bucket_region, :string, public?: true
attribute :cloudfront_url, :string, public?: true
attribute :dataplicity_id, :string, public?: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defmodule Orcasite.Repo.Migrations.UpdateFeedBucketNonNull do
@moduledoc """
Updates resources based on their most recent snapshots.

This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
alter table(:feeds) do
modify :bucket, :text, null: false
end
end

def down do
alter table(:feeds) do
modify :bucket, :text, null: true
end
end
end
317 changes: 317 additions & 0 deletions server/priv/resource_snapshots/repo/feeds/20240909214708.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
{
"attributes": [
{
"allow_nil?": false,
"default": "fragment(\"uuid_generate_v7()\")",
"generated?": false,
"primary_key?": true,
"references": null,
"size": null,
"source": "id",
"type": "uuid"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "name",
"type": "text"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "node_name",
"type": "text"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "slug",
"type": "text"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "location_point",
"type": "geometry"
},
{
"allow_nil?": true,
"default": "\"\"",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "intro_html",
"type": "text"
},
{
"allow_nil?": true,
"default": "\"\"",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "image_url",
"type": "text"
},
{
"allow_nil?": true,
"default": "true",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "visible",
"type": "boolean"
},
{
"allow_nil?": false,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "bucket",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "bucket_region",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "cloudfront_url",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "dataplicity_id",
"type": "text"
},
{
"allow_nil?": true,
"default": "nil",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "orcahello_id",
"type": "text"
},
{
"allow_nil?": false,
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "inserted_at",
"type": "utc_datetime_usec"
},
{
"allow_nil?": false,
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"generated?": false,
"primary_key?": false,
"references": null,
"size": null,
"source": "updated_at",
"type": "utc_datetime_usec"
}
],
"base_filter": null,
"check_constraints": [],
"custom_indexes": [
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"name"
],
"fields": [
{
"type": "atom",
"value": "name"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
},
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"node_name"
],
"fields": [
{
"type": "atom",
"value": "node_name"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
},
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"visible"
],
"fields": [
{
"type": "atom",
"value": "visible"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
},
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"slug"
],
"fields": [
{
"type": "atom",
"value": "slug"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
},
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"dataplicity_id"
],
"fields": [
{
"type": "atom",
"value": "dataplicity_id"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
},
{
"all_tenants?": false,
"concurrently": false,
"error_fields": [
"orcahello_id"
],
"fields": [
{
"type": "atom",
"value": "orcahello_id"
}
],
"include": null,
"message": null,
"name": null,
"nulls_distinct": true,
"prefix": null,
"table": null,
"unique": false,
"using": null,
"where": null
}
],
"custom_statements": [],
"has_create_action": true,
"hash": "7FDF1C3B2AAFBFB7E5DFBE36CD16249F0B95A8F78F8927EE095669FC0F259BB4",
"identities": [
{
"all_tenants?": false,
"base_filter": null,
"index_name": "feeds_unique_slug_index",
"keys": [
{
"type": "atom",
"value": "slug"
}
],
"name": "unique_slug",
"nils_distinct?": true,
"where": null
}
],
"multitenancy": {
"attribute": null,
"global": null,
"strategy": null
},
"repo": "Elixir.Orcasite.Repo",
"schema": null,
"table": "feeds"
}
4 changes: 2 additions & 2 deletions ui/src/components/Player/DetectionsPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function DetectionsPlayer({
endOffset,
onAudioPlay,
}: {
feed: Pick<Feed, "nodeName">;
feed: Pick<Feed, "nodeName" | "bucket">;
marks: { label: string; value: number }[];
timestamp: number;
startOffset: number;
Expand All @@ -38,7 +38,7 @@ export function DetectionsPlayer({
const sliderMax = endOffset - startOffset;
const sliderValue = playerTime - startOffset;

const hlsURI = getHlsURI(feed.nodeName, timestamp);
const hlsURI = getHlsURI(feed.bucket, feed.nodeName, timestamp);

const playerOptions = useMemo(
() => ({
Expand Down
14 changes: 12 additions & 2 deletions ui/src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ export default function Player({
}: {
currentFeed?: Pick<
Feed,
"id" | "slug" | "nodeName" | "name" | "latLng" | "imageUrl" | "thumbUrl"
| "id"
| "slug"
| "nodeName"
| "name"
| "latLng"
| "imageUrl"
| "thumbUrl"
| "bucket"
>;
}) {
const [playerStatus, setPlayerStatus] = useState<PlayerStatus>("idle");
const playerRef = useRef<VideoJSPlayer | null>(null);

const { timestamp, hlsURI } = useTimestampFetcher(currentFeed?.nodeName);
const { timestamp, hlsURI } = useTimestampFetcher(
currentFeed?.bucket,
currentFeed?.nodeName,
);

const feedPresence = useFeedPresence(currentFeed?.slug);
const listenerCount = feedPresence?.metas.length ?? 0;
Expand Down
Loading
Loading