Class: Databasium::SchemasController

Inherits:
ApplicationController show all
Includes:
Pagy::Method
Defined in:
app/controllers/databasium/schemas_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/databasium/schemas_controller.rb', line 5

def index
  layers = params[:layers].nil? ? nil : params[:layers].presence.try(:to_i) || 1
  model = params[:model]
  if params[:model].present?
    schema = @schema_service.get_model_and_layers_BFS(model, layers)
  else
    schema = @schema_service.schema
  end

  models, pagy = get_models

  respond_to do |format|
    format.html do
      render Views::Databasium::Schemas::Index.new(
               schema: schema,
               models: models,
               pagy: pagy,
               model: model,
               layers: layers
             )
    end
    format.json { render json: @schema }
  end
end


30
31
32
33
34
# File 'app/controllers/databasium/schemas_controller.rb', line 30

def sidebar
  models, pagy = get_models

  render Components::Databasium::SearchResults::SchemaModels.new(models: models, pagy: pagy)
end

#sync_schemaObject



36
37
38
39
# File 'app/controllers/databasium/schemas_controller.rb', line 36

def sync_schema
  @schema_service.sync!
  redirect_back fallback_location: schemas_path
end