diff --git a/Gemfile.lock b/Gemfile.lock index 425ade286..d210645d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -47,15 +47,15 @@ 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) @@ -63,14 +63,14 @@ GEM 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) @@ -78,14 +78,15 @@ GEM 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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/app/helpers/episodes_helper.rb b/app/helpers/episodes_helper.rb index a32f5918d..69ac00c2a 100644 --- a/app/helpers/episodes_helper.rb +++ b/app/helpers/episodes_helper.rb @@ -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" @@ -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" diff --git a/app/models/transcript.rb b/app/models/transcript.rb index 5d47ea312..a76eebaa1 100644 --- a/app/models/transcript.rb +++ b/app/models/transcript.rb @@ -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 diff --git a/app/views/episode_media/_form_status.html.erb b/app/views/episode_media/_form_status.html.erb index f946de163..692900ad3 100644 --- a/app/views/episode_media/_form_status.html.erb +++ b/app/views/episode_media/_form_status.html.erb @@ -21,7 +21,9 @@ <%= form.submit t(".update"), class: "btn btn-primary", data: data %> <% end %> -

<%= t(".updated_at_hint") %>: <%= l(episode.updated_at) %>

+ <% if episode_media_updated_at(episode).present? %> +

<%= t(".updated_at_hint") %>: <%= local_time_ago(episode_media_updated_at(episode)) %>

+ <% end %> diff --git a/app/views/episode_transcripts/_form.html.erb b/app/views/episode_transcripts/_form.html.erb index ad1813c2c..e069e9594 100644 --- a/app/views/episode_transcripts/_form.html.erb +++ b/app/views/episode_transcripts/_form.html.erb @@ -5,19 +5,24 @@ <%= form.submit class: "d-none" %> <%= turbo_frame_tag "episode-form-transcript", data: {controller: "media-upload"} do %> -
-
-
-
- <%= 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| %> +
+
+
+
+ <%= render "form_transcript", episode: episode, fields: fields %> + <%= render "form_main", fields: fields %> +
+
+
+ <%= render "form_status", episode: episode, form: form %>
-
-
- <%= render "form_status", episode: episode, form: form %>
-
+ <% end %> <% end %> <%= render "layouts/stale_record_modal", form: form, discard_path: episode_transcripts_path(episode) %> diff --git a/app/views/episode_transcripts/_form_main.html.erb b/app/views/episode_transcripts/_form_main.html.erb index ad029d198..439243c4f 100644 --- a/app/views/episode_transcripts/_form_main.html.erb +++ b/app/views/episode_transcripts/_form_main.html.erb @@ -1,9 +1,7 @@ -<%= form.fields_for :transcript, episode.transcript, include_id: false do |fields| %> -
-
- <%= fields.select :format, episode_transcript_options, {} %> - <%= fields.label :format, required: true %> - <%= field_help_text t(".help.transcript") %> -
+
+
+ <%= fields.select :format, episode_transcript_options, {} %> + <%= fields.label :format, required: true %> + <%= field_help_text t(".help.transcript") %>
-<% end %> +
diff --git a/app/views/episode_transcripts/_form_status.html.erb b/app/views/episode_transcripts/_form_status.html.erb index 3749ed134..5945e6656 100644 --- a/app/views/episode_transcripts/_form_status.html.erb +++ b/app/views/episode_transcripts/_form_status.html.erb @@ -12,6 +12,8 @@ <%= form.submit t(".update"), class: "btn btn-primary", data: data %> <% end %>
-

<%= t(".updated_at_hint") %>: <%= l(episode.updated_at) %>

+ <% if episode.transcript.persisted? %> +

<%= t(".updated_at_hint") %>: <%= local_time_ago(episode.transcript.updated_at) %>

+ <% end %>
diff --git a/app/views/episode_transcripts/_form_transcript.html.erb b/app/views/episode_transcripts/_form_transcript.html.erb index 3ded4fd7e..7dabcdbea 100644 --- a/app/views/episode_transcripts/_form_transcript.html.erb +++ b/app/views/episode_transcripts/_form_transcript.html.erb @@ -1,13 +1,8 @@
<%= 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 %>
diff --git a/test/models/transcript_test.rb b/test/models/transcript_test.rb index 4372a4e51..7609eadab 100644 --- a/test/models/transcript_test.rb +++ b/test/models/transcript_test.rb @@ -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?