Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PD-112: Update and refactor multi-table / association consumption #186

Merged
merged 12 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
spec fixes
  • Loading branch information
Daniel Orner committed Apr 27, 2023
commit b8d913ca9d0b615ac4c7a7cbd0b546ae4b9e6ca9
4 changes: 2 additions & 2 deletions lib/deimos/active_record_consume/batch_consumption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def upsert_records(messages)

return if record_list.empty?

key_col_proc = self.method(:key_columns).to_proc if self.respond_to?(:key_columns)
col_proc = self.method(:columns).to_proc if self.respond_to?(:columns)
key_col_proc = self.method(:key_columns).to_proc
col_proc = self.method(:columns).to_proc

updater = MassUpdater.new(@klass,
key_col_proc: key_col_proc,
Expand Down
6 changes: 1 addition & 5 deletions lib/deimos/active_record_consume/mass_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ class MassUpdater

# @param klass [Class < ActiveRecord::Base]
def default_keys(klass)
klass.connection.
indexes(klass.table_name).
select(&:unique).
map(&:columns).
flatten
[klass.primary_key]
end

# @param klass [Class < ActiveRecord::Base]
Expand Down
3 changes: 3 additions & 0 deletions spec/active_record_batch_consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ def deleted_query(records)
Widget.create!(test_id: 'xxx', some_int: 2, part_one: 'ghi', part_two: 'jkl')
Widget.create!(test_id: 'yyy', some_int: 7, part_one: 'mno', part_two: 'pqr')

allow_any_instance_of(MyBatchConsumer).to receive(:key_columns).
and_return(%w(part_one part_two))

publish_batch(
[
{ key: { part_one: 'abc', part_two: 'def' }, # To be created
Expand Down