Class: DbdocEngine::AdminDashboardQueries
- Inherits:
-
Object
- Object
- DbdocEngine::AdminDashboardQueries
- Defined in:
- app/queries/dbdoc_engine/admin_dashboard_queries.rb
Class Method Summary collapse
-
.columns_count ⇒ Integer
Get total count of columns across all tables.
-
.filtered_changelogs(params) ⇒ ActiveRecord::Relation
Get filtered changelogs for audit history.
-
.groups_count ⇒ Integer
Get total count of table groups.
-
.prepare_chart_data(changelogs) ⇒ Hash
Format changelog data for chart visualization.
-
.tables_count ⇒ Integer
Get total count of dynamic tables.
Class Method Details
.columns_count ⇒ Integer
Get total count of columns across all tables
21 22 23 |
# File 'app/queries/dbdoc_engine/admin_dashboard_queries.rb', line 21 def columns_count DbDesignDynamicColumn.count end |
.filtered_changelogs(params) ⇒ ActiveRecord::Relation
Get filtered changelogs for audit history
29 30 31 32 33 |
# File 'app/queries/dbdoc_engine/admin_dashboard_queries.rb', line 29 def filtered_changelogs(params) scope = DbDesignChangelog.order(change_timestamp: :desc) scope = scope.where(action_type: params[:action_type]) if params[:action_type].present? scope end |
.groups_count ⇒ Integer
Get total count of table groups
9 10 11 |
# File 'app/queries/dbdoc_engine/admin_dashboard_queries.rb', line 9 def groups_count DbDesignTableGroup.count end |
.prepare_chart_data(changelogs) ⇒ Hash
Format changelog data for chart visualization
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/queries/dbdoc_engine/admin_dashboard_queries.rb', line 40 def prepare_chart_data(changelogs) # Define entity types for chart categorization entities = %w[table_group table column] # Extract unique action types from changelogs action_types = changelogs.pluck(:action_type).uniq # Build datasets for each action type datasets = action_types.map do |action| { label: action.titleize, # Count occurrences per entity type for this action data: entities.map { |e| changelogs.count { |log| log.action_type == action && log.entity_type == e } }, # Assign color based on action type backgroundColor: case action when 'create' then '#4CAF50' # Green when 'update' then '#FFC107' # Amber when 'delete' then '#F44336' # Red else '#CCCCCC' # Default gray end } end # Return structured chart data { labels: %w[Groups Tables Columns], # X-axis labels datasets: datasets # Data series collection } end |
.tables_count ⇒ Integer
Get total count of dynamic tables
15 16 17 |
# File 'app/queries/dbdoc_engine/admin_dashboard_queries.rb', line 15 def tables_count DbDesignDynamicTable.count end |