Sha256: a4bbb234fa27205e5e1eb615638c8b683146d16f6df6f1da42e9030aa6f895aa
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# ARQLogger This is ActiveRecord Query Logger. This gem logs count of query and duration of only querying. # Installation ``` gem 'a_r_q_logger' ``` or ``` gem 'a_r_q_logger', require: false require 'a_r_q_logger' ``` # Usage ## In tests ## count queries ``` before :all do 10.times { TestChildModel.create!(test_model: TestModel.create!, name: SecureRandom.hex(4)) } end it do expect(ARQLogger.log { TestModel.includes(:test_child_models).all.each { |m| m.test_child_models.map(&:name) } }.count).to eq(2) end it do expect(ARQLogger.log { TestModel.all.each { |m| m.test_child_models.map(&:name) } }.count).to eq(11) end ``` ## count instantiating ``` before :all do 10.times { TestChildModel.create!(test_model: TestModel.create!, name: SecureRandom.hex(4)) } end it do expect(ARQLogger.log { TestModel.includes(:test_child_models).load }.instances).to eq(20) end it do expect(ARQLogger.log { TestModel.joins(:test_child_models).select('test_child_models.id as as_id').load }.instances).to eq(10) end ``` ## In Anywhere ``` pry(main)> ARQLogger.log { 3.times { TestModel.has_children(10).map(&:children_count) } } => #<struct ARQLogger::Result count=3, msec=1508.4> ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
a_r_q_logger-0.0.7 | README.md |