Class: Dbviewer::Api::EntityRelationshipDiagramsController

Inherits:
BaseController show all
Defined in:
app/controllers/dbviewer/api/entity_relationship_diagrams_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#render_error, #render_success

Methods included from DatabaseOperations

#database_manager, #table_query_operations

Methods included from DatatableSupport

#fetch_datatable_data

Methods included from DataExport

#export_table_to_csv

Methods included from QueryOperations

#default_query, #execute_query, #prepare_query

Methods included from RelationshipManagement

#fetch_mini_erd_for_table, #fetch_table_relationships

Methods included from TableOperations

#fetch_filtered_record_count, #fetch_table_columns, #fetch_table_metadata, #fetch_table_record_count, #fetch_table_records, #fetch_tables, #safe_quote_table_name

Methods included from DatabaseInformation

#fetch_database_analytics, #get_adapter_name, #get_database_name

Methods included from ConnectionManagement

#available_connections, #current_connection_key, #switch_connection

Instance Method Details

#relationshipsObject



6
7
8
9
10
11
12
# File 'app/controllers/dbviewer/api/entity_relationship_diagrams_controller.rb', line 6

def relationships
  @table_relationships = fetch_table_relationships(@tables)
  render_success({
    relationships: @table_relationships,
    status: "success"
  })
end

#table_relationshipsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/dbviewer/api/entity_relationship_diagrams_controller.rb', line 14

def table_relationships
  table_names = params[:tables]&.split(",") || []

  relationships = table_names
    .filter { |table_name| @tables.any? { |t| t[:name] == table_name } }
    .flat_map { |table_name| extract_table_relationships(table_name) }

  render_success({
    relationships: relationships,
    status: "success",
    processed_tables: table_names
  })
end