Skip to content

Commit

Permalink
add indexes on payment transactions model (#4830)
Browse files Browse the repository at this point in the history
  • Loading branch information
saipraveen18 authored and saikumar9 committed Dec 13, 2024
1 parent c30ec16 commit 2601a9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit 2601a9b

Please sign in to comment.