diff --git a/Gemfile b/Gemfile index edec4b7f812caf2af0cb6b27f81ebd7c14e8f631..766d0c6590eadc140eefb43bd37970b4c4385392 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'two_factor_authentication', git: 'https://github.com/noesya/two_factor_auth gem 'jquery-rails' gem 'sassc-rails' gem 'jbuilder' -gem 'kamifusen' +gem 'kamifusen'#, path: '../kamifusen' gem 'bootstrap' gem 'sanitize' diff --git a/app/models/communication/website/with_media.rb b/app/models/communication/website/with_media.rb index 4ec63e11df6a0b94b102092de61ad48192232fd8..5b7203e9a9e8325198b21d4d2732af85edc905ff 100644 --- a/app/models/communication/website/with_media.rb +++ b/app/models/communication/website/with_media.rb @@ -1,6 +1,10 @@ module Communication::Website::WithMedia extend ActiveSupport::Concern + included do + after_save_commit :publish_media_to_github + end + def active_storage_blobs blob_ids = [featured_image&.blob_id, text.embeds.blobs.pluck(:id)].flatten.compact university.active_storage_blobs.where(id: blob_ids) @@ -20,8 +24,7 @@ module Communication::Website::WithMedia protected - def publish_to_github - super + def publish_media_to_github active_storage_blobs.each do |blob| blob.analyze unless blob.analyzed? github.publish(path: blob_github_path_generated(blob), @@ -29,4 +32,5 @@ module Communication::Website::WithMedia data: blob_to_jekyll(blob)) end end + handle_asynchronously :publish_media_to_github, queue: 'default' end diff --git a/app/models/concerns/with_github.rb b/app/models/concerns/with_github.rb index 65fea1ba15a4a4915f162202402ef9e0db24d7d4..d3d0f0a36603267a0a191006b69e92853ff3ae37 100644 --- a/app/models/concerns/with_github.rb +++ b/app/models/concerns/with_github.rb @@ -2,7 +2,7 @@ module WithGithub extend ActiveSupport::Concern included do - after_save :publish_to_github + after_save_commit :publish_to_github end def force_publish!