forked from rauversion/rauversion-phx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oban: process audio in oban job (rauversion#36)
* oban: process audio in oban job * update active job * track state * test oban * notices on show and tracks for pending state
- Loading branch information
Showing
15 changed files
with
187 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule Rauversion.Workers.TrackProcessorWorker do | ||
use Oban.Worker, queue: :default, max_attempts: 1 | ||
|
||
# alias MyApp.{Endpoint, Zipper} | ||
|
||
def perform(%_{args: %{"track_id" => track_id, "file" => file}}) do | ||
struct = Rauversion.Tracks.get_track!(track_id) |> Rauversion.Tracks.change_track() | ||
|
||
Rauversion.Tracks.broadcast_change({:ok, struct.data}, [:tracks, :mp3_converting]) | ||
|
||
file = file |> Map.new(fn {k, v} -> {String.to_atom(k), v} end) | ||
|
||
%{path: path, blob: blob} = Rauversion.Tracks.Track.convert_to_mp3(struct, file) | ||
|
||
Rauversion.Tracks.Track.process_peaks(struct, blob, path) | ||
|
||
:ok | ||
end | ||
|
||
# ... | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
priv/repo/migrations/20220722054446_add_oban_jobs_table.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Rauversion.Repo.Migrations.AddObanJobsTable do | ||
use Ecto.Migration | ||
|
||
def up do | ||
Oban.Migrations.up() | ||
end | ||
|
||
def down do | ||
Oban.Migrations.down(version: 1) | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
priv/repo/migrations/20220722134234_add_state_to_track.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Rauversion.Repo.Migrations.AddStateToTrack do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:tracks) do | ||
add :state, :string | ||
end | ||
|
||
create index(:tracks, [:state]) | ||
end | ||
end |