Skip to content

Commit

Permalink
speed up entries display by no longer looking at all the statusable o…
Browse files Browse the repository at this point in the history
…bjects
  • Loading branch information
orangewolf committed Dec 3, 2024
1 parent ca08ee4 commit cb30c76
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/bulkrax/datatables_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def format_entries(entries, item)
status_message: status_message_for(e),
type: e.type,
updated_at: e.updated_at,
errors: e.latest_status&.error_class&.present? ? view_context.link_to(e.latest_status.error_class, view_context.item_entry_path(item, e), title: e.latest_status.error_message) : "",
errors: e.status_message == 'Failed' ? view_context.link_to(e.error_class, view_context.item_entry_path(item, e)) : "",
actions: entry_util_links(e, item)
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/bulkrax/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Bulkrax
class Status < ApplicationRecord
belongs_to :statusable, polymorphic: true, denormalize: { fields: %i[status_message], if: :latest? }
belongs_to :statusable, polymorphic: true, denormalize: { fields: %i[status_message error_class], if: :latest? }
belongs_to :runnable, polymorphic: true
serialize :error_backtrace, Array

Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241203010707_entry_error_denormalization.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class EntryErrorDenormalization < ActiveRecord::Migration[6.1]
def change
add_column :bulkrax_entries, :error_class, :string unless column_exists?(:bulkrax_entries, :error_class)
end
end
2 changes: 1 addition & 1 deletion lib/tasks/bulkrax_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace :bulkrax do
progress_mark: ' ',
remainder_mark: "\u{FF65}")
Bulkrax::Status.latest_by_statusable.includes(:statusable).find_each do |status|
status.statusable.update(status_message: status.status_message)
status.statusable.update(status_message: status.status_message, error_class: status.error_class)
@progress.increment
end
end
Expand Down

0 comments on commit cb30c76

Please sign in to comment.