Skip to content

Commit

Permalink
More debugging which can be helpful
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Feb 27, 2024
1 parent e16acbd commit b5a7c09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/searchcraft/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,20 @@ def recreate_view_if_changed!(builders_changed: [])
end

def create_view!
warn "Creating view/sequence/indexes for #{view_name}..." if SearchCraft.debug?
create_sequence!
sql_execute(view_sql)
create_indexes!
end

# Finds and drops all indexes and sequences on view, and then drops view
def drop_view!
puts "Dropping view/sequence for #{view_name}..." if SearchCraft.debug?
sql_execute("DROP MATERIALIZED VIEW IF EXISTS #{view_name} CASCADE;")

sql_execute("DROP SEQUENCE IF EXISTS #{view_id_sequence_name};")

warn "Updating ViewHashStore for #{self.class.name}" if SearchCraft.debug?
SearchCraft::ViewHashStore.reset!(builder: self)
end

Expand Down
1 change: 1 addition & 0 deletions lib/searchcraft/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def self.included_classes

module ClassMethods
def refresh!
puts "Refreshing materialized view #{table_name}..." if SearchCraft.debug?
Scenic.database.refresh_materialized_view(table_name, concurrently: @refresh_concurrently, cascade: false)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/refresh.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace :searchcraft do
require "benchmark"
SearchCraft.config.explicit_model_class_names.each do |model_class_name|
klass = model_class_name.constantize
puts "Refreshing materialized views for #{klass.name}"
warn "Refreshing materialized views for #{klass.name}"
puts Benchmark.measure { klass.refresh! }
end
end
Expand Down

0 comments on commit b5a7c09

Please sign in to comment.