Module: QuickCount
- Defined in:
- lib/quick_count.rb,
lib/quick_count/railtie.rb,
lib/quick_count/version.rb,
lib/quick_count/active_record.rb
Defined Under Namespace
Modules: ActiveRecord
Classes: Railtie
Constant Summary
collapse
- VERSION =
"0.1.2"
Class Method Summary
collapse
Class Method Details
.install(threshold: 500000, schema: 'public', connection: ::ActiveRecord::Base.connection) ⇒ Object
16
17
18
19
|
# File 'lib/quick_count.rb', line 16
def self.install(threshold: 500000, schema: 'public', connection: ::ActiveRecord::Base.connection)
connection.execute(quick_count_sql(schema: schema, threshold: threshold))
connection.execute(count_estimate_sql(schema: schema))
end
|
.load ⇒ Object
11
12
13
14
|
# File 'lib/quick_count.rb', line 11
def self.load
::ActiveRecord::Base.send :include, QuickCount::ActiveRecord
::ActiveRecord::Relation.send :include, CountEstimate::ActiveRecord
end
|
.root ⇒ Object
7
8
9
|
# File 'lib/quick_count.rb', line 7
def self.root
@root ||= Pathname.new(File.dirname(File.expand_path(File.dirname(__FILE__), '/../')))
end
|
.uninstall(schema: 'public', connection: ::ActiveRecord::Base.connection) ⇒ Object
21
22
23
24
25
|
# File 'lib/quick_count.rb', line 21
def self.uninstall(schema: 'public', connection: ::ActiveRecord::Base.connection)
connection.execute("DROP FUNCTION IF EXISTS #{schema}.quick_count(text, bigint);")
connection.execute("DROP FUNCTION IF EXISTS #{schema}.quick_count(text);")
connection.execute("DROP FUNCTION IF EXISTS #{schema}.count_estimate(text);")
end
|