Skip to content

Commit

Permalink
Fix lookup of journal_class, not only table
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Aug 7, 2024
1 parent bfd6518 commit 3382a5e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions db/migrate/20220818074159_fix_deleted_data_journals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_missing_journals
Journal
.pluck("DISTINCT(journable_type)")
.to_h do |journable_type|
table_name = lookup_journal_class_table(journable_type)
journal_class, table_name = lookup_journal_class_table(journable_type)
relation = Journal
.joins("LEFT OUTER JOIN #{table_name} ON journals.data_type = '#{journal_class}' AND #{table_name}.id = journals.data_id")
.where("#{table_name}.id IS NULL")
Expand All @@ -131,10 +131,10 @@ def get_missing_journals

# Lookup table for items that were already deleted
def lookup_journal_class_table(journable_type)
lookup = { "WikiContent" => "wiki_content_journals" }
lookup = { "WikiContent" => %w[Journal::WikiContentJournal wiki_content_journals] }
lookup.fetch(journable_type) do
journal_class = journable_type.constantize.journal_class
journal_class.table_name
[journal_class.to_s, journal_class.table_name]
end
end

Expand Down

0 comments on commit 3382a5e

Please sign in to comment.