timgremore commited on
Commit
f94adc3
1 Parent(s): 865b340

feat: Track transcription life cycle with status

Browse files
lib/medical_transcription/transcriptions/transcription.ex CHANGED
@@ -11,6 +11,7 @@ defmodule MedicalTranscription.Transcriptions.Transcription do
11
  schema "transcriptions" do
12
  field :filename, :string
13
  field :recording_length_in_seconds, :integer
 
14
 
15
  belongs_to :user, MedicalTranscription.Accounts.User
16
 
 
11
  schema "transcriptions" do
12
  field :filename, :string
13
  field :recording_length_in_seconds, :integer
14
+ field :status, Ecto.Enum, values: [new: 0, waiting: 1, transcribing: 2, finished: 3, failed: 4]
15
 
16
  belongs_to :user, MedicalTranscription.Accounts.User
17
 
lib/medical_transcription_web/components/components.ex CHANGED
@@ -73,6 +73,7 @@ defmodule MedicalTranscriptionWeb.Components do
73
 
74
  attr :status, :atom, required: true
75
  attr :filename, :string, default: nil
 
76
  attr :summary_keywords, :list, default: []
77
 
78
  @doc """
@@ -82,18 +83,14 @@ defmodule MedicalTranscriptionWeb.Components do
82
  ~H"""
83
  <div class="flex justify-between">
84
  <div class="flex items-center">
85
- <%= case @status do %>
86
- <% status when status in [:loading, :streaming_audio] -> %>
87
- <img src={~p"/images/loading.svg"} width="36" class="mr-6 animate-spin" />
88
- <% :success -> %>
89
- <img src={~p"/images/checkmark.svg"} width="46" class="mr-[17px]" />
90
- <% end %>
91
 
92
- <.record_button_in_heading status={@status} />
93
 
94
  <div class="px-[14px] py-3 flex items-center gap-3 bg-brand rounded-lg text-white">
95
  <img src={~p"/images/document.svg"} width="20" />
96
- <span class="font-secondary"><%= @filename %></span>
97
  </div>
98
  </div>
99
  <button phx-click="reset_to_pending" type="button" class="p-3 rounded-lg bg-[#444444]/10">
 
73
 
74
  attr :status, :atom, required: true
75
  attr :filename, :string, default: nil
76
+ attr :transcription, MedicalTranscription.Transcriptions.Transcription, required: true
77
  attr :summary_keywords, :list, default: []
78
 
79
  @doc """
 
83
  ~H"""
84
  <div class="flex justify-between">
85
  <div class="flex items-center">
86
+ <img :if={@transcription.status == :waiting} src={~p"/images/loading.svg"} width="36" class="mr-6 animate-spin" />
87
+ <img :if={@transcription.status == :finished} src={~p"/images/checkmark.svg"} width="46" class="mr-[17px]" />
 
 
 
 
88
 
89
+ <.record_button_in_heading status={@transcription.status} />
90
 
91
  <div class="px-[14px] py-3 flex items-center gap-3 bg-brand rounded-lg text-white">
92
  <img src={~p"/images/document.svg"} width="20" />
93
+ <span class="font-secondary"><%= @transcription.filename %></span>
94
  </div>
95
  </div>
96
  <button phx-click="reset_to_pending" type="button" class="p-3 rounded-lg bg-[#444444]/10">
lib/medical_transcription_web/live/transcriptions_live/show.ex CHANGED
@@ -47,13 +47,10 @@ defmodule MedicalTranscriptionWeb.TranscriptionsLive.Show do
47
 
48
  <main class="flex-1 pl-16 pr-16 pt-[25px]">
49
  <div class="flex flex-col h-full mx-auto max-w-5xl">
50
- <%= if Enum.member?([:loading, :streaming_audio, :success], assigns.status) do %>
51
- <.result_heading
52
- status={@status}
53
- filename={@uploaded_file_name}
54
- summary_keywords={@summary_keywords}
55
- />
56
- <% end %>
57
 
58
  <div id="result_list" class="flex flex flex-col gap-14" phx-update="stream">
59
  <.live_component
 
47
 
48
  <main class="flex-1 pl-16 pr-16 pt-[25px]">
49
  <div class="flex flex-col h-full mx-auto max-w-5xl">
50
+ <.result_heading
51
+ transcription={@transcription}
52
+ summary_keywords={@summary_keywords}
53
+ />
 
 
 
54
 
55
  <div id="result_list" class="flex flex flex-col gap-14" phx-update="stream">
56
  <.live_component
priv/repo/migrations/20240209142258_add_status_to_transcriptions.exs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ defmodule MedicalTranscription.Repo.Migrations.AddStatusToTranscriptions do
2
+ use Ecto.Migration
3
+
4
+ def change do
5
+ alter table("transcriptions") do
6
+ add :status, :integer, null: false, default: 0
7
+ end
8
+ end
9
+ end