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

add indexes on payment transactions model #4830

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion app/models/payment_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class PaymentTransaction
include Mongoid::Document
include Mongoid::Timestamps

belongs_to :family
belongs_to :family, index: true

field :payment_transaction_id, type: String
field :carrier_id, type: BSON::ObjectId
Expand All @@ -13,6 +13,12 @@ class PaymentTransaction
field :submitted_at, type: DateTime
field :source, type: String

index({ status: 1 })
index({ enrollment_id: 1 })
index({ enrollment_effective_date: 1 })
index({ payment_transaction_id: 1 })
index({ carrier_id: 1 })

before_save :generate_payment_transaction_id, :set_submitted_at

def generate_payment_transaction_id
Expand Down
11 changes: 11 additions & 0 deletions spec/models/payment_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@
expect(subject.source).to eq source
end
end

context "payment transactions" do
it 'should have the indexes' do
PaymentTransaction.create_indexes
indexes = PaymentTransaction.collection.indexes.map { |index| index['key'] }
expect(indexes).to include({:family_id => 1})
expect(indexes).to include({:status => 1})
expect(indexes).to include({:enrollment_id => 1})
expect(indexes).to include({:payment_transaction_id => 1})
end
end
end
Loading