Skip to content

Commit

Permalink
Fix 'bulk' method missing error when resource has a bulk date (confli…
Browse files Browse the repository at this point in the history
…cts with ASModel::ChangeTracking)
  • Loading branch information
payten committed Jul 28, 2020
1 parent 2fcb0ad commit 287e49e
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions backend/model/ladybird_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ def prepare_resource_creation_dates
.select(:id)
.first[:id]

bulk_type_enum_id = EnumerationValue
.filter(:enumeration_id => Enumeration.filter(:name => 'date_type').select(:id))
.filter(:value => 'bulk')
.select(:id)
.first[:id]

ASDate
.filter(:date__resource_id => @resource_id)
.select(:resource_id,
Expand All @@ -306,10 +300,6 @@ def prepare_resource_creation_dates
@all_resource_dates[row[:resource_id]] << row

if row[:label_id] == creation_enum_id
if row[:date_type_id] == bulk_type_enum_id
row[:bulk] = true
end

@resource_creation_dates[row[:resource_id]] ||= []
@resource_creation_dates[row[:resource_id]] << row
end
Expand All @@ -326,12 +316,6 @@ def prepare_ao_creation_dates
.select(:id)
.first[:id]

bulk_type_enum_id = EnumerationValue
.filter(:enumeration_id => Enumeration.filter(:name => 'date_type').select(:id))
.filter(:value => 'bulk')
.select(:id)
.first[:id]

ASDate
.filter(:date__archival_object_id => @ids)
.select(:archival_object_id,
Expand All @@ -345,10 +329,6 @@ def prepare_ao_creation_dates
@all_dates[row[:archival_object_id]] << row

if row[:label_id] == creation_enum_id
if row[:date_type_id] == bulk_type_enum_id
row[:bulk] = true
end

@creation_dates[row[:archival_object_id]] ||= []
@creation_dates[row[:archival_object_id]] << row
end
Expand Down Expand Up @@ -826,8 +806,8 @@ def collection_creation_years(row)

return if dates.empty?

non_bulk = dates.select{|d| !d[:bulk]}
bulk = dates.select{|d| d[:bulk]}.first
non_bulk = dates.select{|d| d.date_type != 'bulk'}
bulk = dates.find{|d| d.date_type == 'bulk'}

def fmt_date(date)
date[:expression] || [(date[:begin] || '').sub(/-.*/, ''), (date[:end] || '').sub(/-.*/, '')].select{|d| !d.empty?}.compact.uniq.join('-')
Expand Down

0 comments on commit 287e49e

Please sign in to comment.