Skip to content

Commit

Permalink
support index option for activities and events
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Mar 7, 2020
1 parent f2e5a5c commit 20fb28c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def self.import_by_ids(options={})

# get every id between from_id and end_id
(from_id..until_id).step(500).each do |id|
ActivityImportByIdJob.perform_later(id: id)
ActivityImportByIdJob.perform_later(options.merge(id: id))
end

(from_id..until_id).to_a.length
Expand All @@ -71,7 +71,13 @@ def self.import_by_id(options={})
return nil if options[:id].blank?

id = options[:id].to_i
index = Rails.env.test? ? "activities-test" : self.inactive_index
index = if Rails.env.test?
"activities-test"
elsif options[:index].present?
options[:index]
else
self.inactive_index
end
errors = 0
count = 0

Expand Down
9 changes: 7 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def self.import_by_ids(options = {})

# get every id between from_id and until_id
(from_id..until_id).step(500).each do |id|
EventImportByIdJob.perform_later(id: id)
EventImportByIdJob.perform_later(options.merge(id: id))
Rails.logger.info "Queued importing for events with IDs starting with #{id}." unless Rails.env.test?
end
end
Expand All @@ -264,8 +264,13 @@ def self.import_by_id(options = {})
return nil unless options[:id].present?

id = options[:id].to_i
index = Rails.env.test? ? "events-test" : self.inactive_index
index = if Rails.env.test?
"events-test"
elsif options[:index].present?
options[:index]
else
self.inactive_index
end
errors = 0
count = 0

Expand Down

0 comments on commit 20fb28c

Please sign in to comment.