Skip to content

Commit

Permalink
Merge branch 'main' into fix/apple_dd
Browse files Browse the repository at this point in the history
  • Loading branch information
kookster committed Nov 2, 2024
2 parents dca482b + 063af20 commit bfad45f
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 92 deletions.
111 changes: 57 additions & 54 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.1.2)
actionpack (= 7.2.1.2)
activesupport (= 7.2.1.2)
actioncable (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.1.2)
actionpack (= 7.2.1.2)
activejob (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
actionmailbox (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
mail (>= 2.8.0)
actionmailer (7.2.1.2)
actionpack (= 7.2.1.2)
actionview (= 7.2.1.2)
activejob (= 7.2.1.2)
activesupport (= 7.2.1.2)
actionmailer (7.2.2)
actionpack (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activesupport (= 7.2.2)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.1.2)
actionview (= 7.2.1.2)
activesupport (= 7.2.1.2)
actionpack (7.2.2)
actionview (= 7.2.2)
activesupport (= 7.2.2)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
Expand All @@ -47,45 +47,46 @@ GEM
useragent (~> 0.16)
actionpack-action_caching (1.2.2)
actionpack (>= 4.0.0)
actiontext (7.2.1.2)
actionpack (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
actiontext (7.2.2)
actionpack (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.1.2)
activesupport (= 7.2.1.2)
actionview (7.2.2)
activesupport (= 7.2.2)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_link_to (1.0.5)
actionpack
addressable
activejob (7.2.1.2)
activesupport (= 7.2.1.2)
activejob (7.2.2)
activesupport (= 7.2.2)
globalid (>= 0.3.6)
activemodel (7.2.1.2)
activesupport (= 7.2.1.2)
activerecord (7.2.1.2)
activemodel (= 7.2.1.2)
activesupport (= 7.2.1.2)
activemodel (7.2.2)
activesupport (= 7.2.2)
activerecord (7.2.2)
activemodel (= 7.2.2)
activesupport (= 7.2.2)
timeout (>= 0.4.0)
activerecord-session_store (2.0.0)
actionpack (>= 5.2.4.1)
activerecord (>= 5.2.4.1)
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (7.2.1.2)
actionpack (= 7.2.1.2)
activejob (= 7.2.1.2)
activerecord (= 7.2.1.2)
activesupport (= 7.2.1.2)
activestorage (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activesupport (= 7.2.2)
marcel (~> 1.0)
activesupport (7.2.1.2)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
Expand Down Expand Up @@ -128,6 +129,7 @@ GEM
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
benchmark (0.3.0)
better_html (2.0.2)
actionview (>= 6.0)
activesupport (>= 6.0)
Expand Down Expand Up @@ -308,7 +310,7 @@ GEM
net-smtp (0.5.0)
net-protocol
newrelic_rpm (8.13.1)
nio4r (2.7.3)
nio4r (2.7.4)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
Expand Down Expand Up @@ -571,20 +573,20 @@ GEM
rackup (1.0.1)
rack (< 3)
webrick
rails (7.2.1.2)
actioncable (= 7.2.1.2)
actionmailbox (= 7.2.1.2)
actionmailer (= 7.2.1.2)
actionpack (= 7.2.1.2)
actiontext (= 7.2.1.2)
actionview (= 7.2.1.2)
activejob (= 7.2.1.2)
activemodel (= 7.2.1.2)
activerecord (= 7.2.1.2)
activestorage (= 7.2.1.2)
activesupport (= 7.2.1.2)
rails (7.2.2)
actioncable (= 7.2.2)
actionmailbox (= 7.2.2)
actionmailer (= 7.2.2)
actionpack (= 7.2.2)
actiontext (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activemodel (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
bundler (>= 1.15.0)
railties (= 7.2.1.2)
railties (= 7.2.2)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -596,9 +598,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.2.1.2)
actionpack (= 7.2.1.2)
activesupport (= 7.2.1.2)
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand Down Expand Up @@ -745,6 +747,7 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-21
x86_64-darwin-22
x86_64-darwin-23
Expand Down
14 changes: 10 additions & 4 deletions app/helpers/episodes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ def episode_status_class(episode)
end

def episode_media_status(episode)
all_media = episode.media.append(episode.uncut).compact.reject(&:new_record?)

if all_media.any? { |m| upload_problem?(m) }
if episode_all_media(episode).any? { |m| upload_problem?(m) }
"error"
elsif all_media.any? { |m| upload_processing?(m) }
elsif episode_all_media(episode).any? { |m| upload_processing?(m) }
"processing"
elsif episode.media_ready?(true)
"complete"
Expand Down Expand Up @@ -119,6 +117,14 @@ def episode_medium_options
Episode.mediums.keys.map { |k| [I18n.t("helpers.label.episode.mediums.#{k}"), k] }
end

def episode_media_updated_at(episode)
episode_all_media(episode).maximum(:updated_at)
end

def episode_all_media(episode)
episode.media.append(episode.uncut).compact.reject(&:new_record?)
end

def episode_category_button_class(episode, value)
if episode.categories.include?(value)
"btn-primary"
Expand Down
2 changes: 1 addition & 1 deletion app/models/transcript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Transcript < ApplicationRecord

acts_as_paranoid

belongs_to :episode
belongs_to :episode, -> { with_deleted }, touch: true, optional: true

has_one :task, -> { order("id desc") }, as: :owner
has_many :tasks, as: :owner
Expand Down
4 changes: 3 additions & 1 deletion app/views/episode_media/_form_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<%= form.submit t(".update"), class: "btn btn-primary", data: data %>
<% end %>
</div>
<p class="status-text mt-2 mb-0 text-end"><strong><%= t(".updated_at_hint") %>:</strong> <%= l(episode.updated_at) %></p>
<% if episode_media_updated_at(episode).present? %>
<p class="status-text mt-2 mb-0 text-end"><strong><%= t(".updated_at_hint") %>:</strong> <%= local_time_ago(episode_media_updated_at(episode)) %></p>
<% end %>
</div>
</div>

Expand Down
25 changes: 15 additions & 10 deletions app/views/episode_transcripts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@
<%= form.submit class: "d-none" %>
<%= turbo_frame_tag "episode-form-transcript", data: {controller: "media-upload"} do %>
<div class="container">
<div class="row mt-4 mx-2">
<div class="col-lg-8">
<div class="row">
<%= render "form_transcript", episode: episode, form: form %>
<%= render "form_main", episode: episode, form: form %>
<% episode.build_transcript if episode.transcript.blank? %>
<% episode.transcript.clear_attribute_changes(%i[format]) %>
<%= form.fields_for :transcript do |fields| %>
<div class="container">
<div class="row mt-4 mx-2">
<div class="col-lg-8">
<div class="row">
<%= render "form_transcript", episode: episode, fields: fields %>
<%= render "form_main", fields: fields %>
</div>
</div>
<div class="col-lg-4 d-grid align-content-start gap-3">
<%= render "form_status", episode: episode, form: form %>
</div>
</div>
<div class="col-lg-4 d-grid align-content-start gap-3">
<%= render "form_status", episode: episode, form: form %>
</div>
</div>
</div>
<% end %>
<% end %>
<%= render "layouts/stale_record_modal", form: form, discard_path: episode_transcripts_path(episode) %>
Expand Down
14 changes: 6 additions & 8 deletions app/views/episode_transcripts/_form_main.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%= form.fields_for :transcript, episode.transcript, include_id: false do |fields| %>
<div class="col-12 mb-4">
<div class="form-floating input-group">
<%= fields.select :format, episode_transcript_options, {} %>
<%= fields.label :format, required: true %>
<%= field_help_text t(".help.transcript") %>
</div>
<div class="col-12 mb-4">
<div class="form-floating input-group">
<%= fields.select :format, episode_transcript_options, {} %>
<%= fields.label :format, required: true %>
<%= field_help_text t(".help.transcript") %>
</div>
<% end %>
</div>
4 changes: 3 additions & 1 deletion app/views/episode_transcripts/_form_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<%= form.submit t(".update"), class: "btn btn-primary", data: data %>
<% end %>
</div>
<p class="status-text mt-2 mb-0 text-end"><strong><%= t(".updated_at_hint") %>:</strong> <%= l(episode.updated_at) %></p>
<% if episode.transcript.persisted? %>
<p class="status-text mt-2 mb-0 text-end"><strong><%= t(".updated_at_hint") %>:</strong> <%= local_time_ago(episode.transcript.updated_at) %></p>
<% end %>
</div>
</div>
11 changes: 3 additions & 8 deletions app/views/episode_transcripts/_form_transcript.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<div class="prx-uploads col-12 mb-2">
<%= turbo_frame_tag "episode-media-form-transcript", data: {controller: "morphdom"} do %>
<% episode.build_transcript if episode.transcript.blank? %>
<% episode.transcript.clear_attribute_changes(%i[format]) %>
<% path = episode_transcripts_path(episode, uploads_destroy_params(fields)) %>
<% rpath = episode_transcripts_path(episode, uploads_retry_params(fields)) %>
<%= form.fields_for :transcript do |fields| %>
<% path = episode_transcripts_path(episode, uploads_destroy_params(fields)) %>
<% rpath = episode_transcripts_path(episode, uploads_retry_params(fields)) %>
<%= render "episode_transcripts/transcripts/form", form: fields, transcript: fields.object, delete_path: path, retry_path: rpath %>
<% end %>
<%= render "episode_transcripts/transcripts/form", form: fields, transcript: fields.object, delete_path: path, retry_path: rpath %>
<% end %>
</div>
5 changes: 0 additions & 5 deletions test/models/transcript_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
assert transcript.valid?
end

it "must belong to an episode" do
transcript.episode = nil
refute transcript.valid?
end

it "requires an original_url" do
transcript.original_url = nil
refute transcript.valid?
Expand Down

0 comments on commit bfad45f

Please sign in to comment.