Class: RspecProfiling::Collectors::PSQL
- Inherits:
-
Object
- Object
- RspecProfiling::Collectors::PSQL
- Defined in:
- lib/rspec_profiling/collectors/psql.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ PSQL
constructor
A new instance of PSQL.
- #insert(attributes) ⇒ Object
- #install ⇒ Object
- #results ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize ⇒ PSQL
Returns a new instance of PSQL.
19 20 21 22 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 19 def initialize RspecProfiling.config.db_path ||= 'rspec_profiling' establish_connection end |
Class Method Details
.install ⇒ Object
7 8 9 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 7 def self.install new.install end |
.reset ⇒ Object
15 16 17 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 15 def self.reset new.results.destroy_all end |
.uninstall ⇒ Object
11 12 13 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 11 def self.uninstall new.uninstall end |
Instance Method Details
#insert(attributes) ⇒ Object
49 50 51 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 49 def insert(attributes) results.create!(attributes.except(:created_at, :events, :event_counts, :event_times, :event_events)) end |
#install ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 24 def install return if prepared? connection.create_table(table) do |t| t.string :branch, index: true t.string :commit_hash, index: true t.datetime :date, index: true t.text :file, index: true t.integer :line_number, index: true t.text :description t.decimal :time, index: true t.string :status, index: true t.text :exception t.integer :query_count, index: true t.decimal :query_time, index:true t.integer :request_count, index: true t.decimal :request_time, index: true t. null: true end end |
#results ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 53 def results @results ||= begin establish_connection Result.table_name = table Result.attr_protected if Result.respond_to?(:attr_protected) Result end end |
#uninstall ⇒ Object
45 46 47 |
# File 'lib/rspec_profiling/collectors/psql.rb', line 45 def uninstall connection.drop_table(table) end |