Class: Dbviewer::LogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dbviewer/logs_controller.rb

Instance Method Summary collapse

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

#destroy_allObject



23
24
25
26
27
28
# File 'app/controllers/dbviewer/logs_controller.rb', line 23

def destroy_all
  dbviewer_logger.clear
  flash[:success] = "Query logs cleared successfully"

  redirect_to logs_path
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/dbviewer/logs_controller.rb', line 6

def index
  @queries = dbviewer_logger.recent_queries(
    limit: @limit,
    table_filter: @table_filter,
    request_id: @request_id,
    min_duration: @min_duration
  )

  if @request_id.present? || @table_filter.present? || @min_duration.present?
    @stats = dbviewer_logger.stats_for_queries(@queries)
    @filtered_stats = true
  else
    @stats = dbviewer_logger.stats
    @filtered_stats = false
  end
end