solidstats 2.0.0 → 3.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -63
  3. data/README.md +27 -33
  4. data/Rakefile +3 -3
  5. data/app/assets/stylesheets/solidstats/application.css +1 -6
  6. data/app/assets/stylesheets/solidstats/dashboard.css +48 -0
  7. data/app/controllers/solidstats/dashboard_controller.rb +81 -62
  8. data/app/controllers/solidstats/logs_controller.rb +72 -0
  9. data/app/controllers/solidstats/performance_controller.rb +25 -0
  10. data/app/controllers/solidstats/productivity_controller.rb +39 -0
  11. data/app/controllers/solidstats/quality_controller.rb +152 -0
  12. data/app/controllers/solidstats/securities_controller.rb +30 -0
  13. data/app/helpers/solidstats/application_helper.rb +124 -11
  14. data/app/helpers/solidstats/performance_helper.rb +87 -0
  15. data/app/helpers/solidstats/productivity_helper.rb +38 -0
  16. data/app/services/solidstats/bundler_audit_service.rb +206 -0
  17. data/app/services/solidstats/coverage_compass_service.rb +335 -0
  18. data/app/services/solidstats/load_lens_service.rb +454 -0
  19. data/app/services/solidstats/log_size_monitor_service.rb +207 -76
  20. data/app/services/solidstats/my_todo_service.rb +242 -0
  21. data/app/services/solidstats/style_patrol_service.rb +319 -0
  22. data/app/views/layouts/solidstats/application.html.erb +8 -2
  23. data/app/views/layouts/solidstats/dashboard.html.erb +84 -0
  24. data/app/views/solidstats/dashboard/dashboard.html.erb +39 -0
  25. data/app/views/solidstats/logs/logs_size.html.erb +409 -0
  26. data/app/views/solidstats/performance/load_lens.html.erb +158 -0
  27. data/app/views/solidstats/productivity/_todo_list.html.erb +49 -0
  28. data/app/views/solidstats/productivity/my_todos.html.erb +84 -0
  29. data/app/views/solidstats/quality/coverage_compass.html.erb +420 -0
  30. data/app/views/solidstats/quality/style_patrol.html.erb +463 -0
  31. data/app/views/solidstats/securities/bundler_audit.html.erb +345 -0
  32. data/app/views/solidstats/shared/_dashboard_card.html.erb +160 -0
  33. data/app/views/solidstats/shared/_quick_actions.html.erb +26 -0
  34. data/config/routes.rb +32 -7
  35. data/lib/generators/solidstats/install/install_generator.rb +28 -2
  36. data/lib/generators/solidstats/install/templates/README +7 -0
  37. data/lib/solidstats/engine.rb +9 -114
  38. data/lib/solidstats/version.rb +1 -1
  39. data/lib/solidstats.rb +2 -299
  40. data/lib/tasks/solidstats_install.rake +2 -122
  41. data/lib/tasks/solidstats_performance.rake +84 -0
  42. metadata +32 -103
  43. data/app/assets/javascripts/solidstats/application.js +0 -257
  44. data/app/assets/javascripts/solidstats/dashboard.js +0 -225
  45. data/app/assets/javascripts/solidstats/gem_metadata.js +0 -554
  46. data/app/assets/stylesheets/solidstats/components/action_button.css +0 -99
  47. data/app/assets/stylesheets/solidstats/components/dashboard.css +0 -151
  48. data/app/assets/stylesheets/solidstats/components/dashboard_header.css +0 -93
  49. data/app/assets/stylesheets/solidstats/components/dashboard_layout.css +0 -97
  50. data/app/assets/stylesheets/solidstats/components/gem_metadata.css +0 -1403
  51. data/app/assets/stylesheets/solidstats/components/navigation.css +0 -80
  52. data/app/assets/stylesheets/solidstats/components/quick_navigation.css +0 -54
  53. data/app/assets/stylesheets/solidstats/components/security.css +0 -332
  54. data/app/assets/stylesheets/solidstats/components/status_badge.css +0 -58
  55. data/app/assets/stylesheets/solidstats/components/summary_card.css +0 -66
  56. data/app/assets/stylesheets/solidstats/components/tab_navigation.css +0 -95
  57. data/app/components/solidstats/base_component.rb +0 -88
  58. data/app/components/solidstats/code_quality/code_quality_section_component.html.erb +0 -0
  59. data/app/components/solidstats/code_quality/code_quality_section_component.rb +0 -0
  60. data/app/components/solidstats/code_quality/section_component.html.erb +0 -45
  61. data/app/components/solidstats/code_quality/section_component.rb +0 -34
  62. data/app/components/solidstats/dashboard_header_component.html.erb +0 -39
  63. data/app/components/solidstats/dashboard_header_component.rb +0 -33
  64. data/app/components/solidstats/previews/action_button_component_preview/button_vs_link.html.erb +0 -6
  65. data/app/components/solidstats/previews/action_button_component_preview/sizes.html.erb +0 -6
  66. data/app/components/solidstats/previews/action_button_component_preview/variants.html.erb +0 -6
  67. data/app/components/solidstats/previews/action_button_component_preview/with_icons.html.erb +0 -6
  68. data/app/components/solidstats/previews/action_button_component_preview.rb +0 -64
  69. data/app/components/solidstats/previews/navigation_component_preview.rb +0 -74
  70. data/app/components/solidstats/previews/stats_overview_component_preview.rb +0 -100
  71. data/app/components/solidstats/previews/status_badge_component_preview/sizes.html.erb +0 -6
  72. data/app/components/solidstats/previews/status_badge_component_preview/statuses.html.erb +0 -6
  73. data/app/components/solidstats/previews/status_badge_component_preview/with_icons.html.erb +0 -6
  74. data/app/components/solidstats/previews/status_badge_component_preview.rb +0 -49
  75. data/app/components/solidstats/previews/summary_card_component_preview/clickable.html.erb +0 -9
  76. data/app/components/solidstats/previews/summary_card_component_preview/dashboard_layout.html.erb +0 -9
  77. data/app/components/solidstats/previews/summary_card_component_preview/statuses.html.erb +0 -6
  78. data/app/components/solidstats/previews/summary_card_component_preview/value_formats.html.erb +0 -6
  79. data/app/components/solidstats/previews/summary_card_component_preview.rb +0 -67
  80. data/app/components/solidstats/quick_navigation_component.html.erb +0 -8
  81. data/app/components/solidstats/quick_navigation_component.rb +0 -21
  82. data/app/components/solidstats/security/gem_impact_analysis_component.html.erb +0 -44
  83. data/app/components/solidstats/security/gem_impact_analysis_component.rb +0 -45
  84. data/app/components/solidstats/security/overview_component.html.erb +0 -21
  85. data/app/components/solidstats/security/overview_component.rb +0 -104
  86. data/app/components/solidstats/security/section_component.html.erb +0 -26
  87. data/app/components/solidstats/security/section_component.rb +0 -52
  88. data/app/components/solidstats/security/timeline_component.html.erb +0 -39
  89. data/app/components/solidstats/security/timeline_component.rb +0 -43
  90. data/app/components/solidstats/tasks_section_component.html.erb +0 -17
  91. data/app/components/solidstats/tasks_section_component.rb +0 -22
  92. data/app/components/solidstats/ui/action_button_component.html.erb +0 -6
  93. data/app/components/solidstats/ui/action_button_component.rb +0 -71
  94. data/app/components/solidstats/ui/dashboard_layout_component.html.erb +0 -19
  95. data/app/components/solidstats/ui/dashboard_layout_component.rb +0 -85
  96. data/app/components/solidstats/ui/navigation_component.html.erb +0 -34
  97. data/app/components/solidstats/ui/navigation_component.rb +0 -72
  98. data/app/components/solidstats/ui/stats_overview_component.html.erb +0 -14
  99. data/app/components/solidstats/ui/stats_overview_component.rb +0 -78
  100. data/app/components/solidstats/ui/status_badge_component.html.erb +0 -6
  101. data/app/components/solidstats/ui/status_badge_component.rb +0 -42
  102. data/app/components/solidstats/ui/summary_card_component.html.erb +0 -12
  103. data/app/components/solidstats/ui/summary_card_component.rb +0 -63
  104. data/app/components/solidstats/ui/tab_navigation_component.html.erb +0 -22
  105. data/app/components/solidstats/ui/tab_navigation_component.rb +0 -79
  106. data/app/controllers/solidstats/gem_metadata_controller.rb +0 -12
  107. data/app/services/solidstats/audit_service.rb +0 -56
  108. data/app/services/solidstats/data_collector_service.rb +0 -83
  109. data/app/services/solidstats/gem_metadata/fetcher_service.rb +0 -136
  110. data/app/services/solidstats/todo_service.rb +0 -114
  111. data/app/views/solidstats/dashboard/_log_monitor.html.erb +0 -759
  112. data/app/views/solidstats/dashboard/_todos.html.erb +0 -151
  113. data/app/views/solidstats/dashboard/audit/_additional_styles.css +0 -22
  114. data/app/views/solidstats/dashboard/audit/_audit_badge.html.erb +0 -5
  115. data/app/views/solidstats/dashboard/audit/_audit_details.html.erb +0 -495
  116. data/app/views/solidstats/dashboard/audit/_audit_summary.html.erb +0 -26
  117. data/app/views/solidstats/dashboard/audit/_no_vulnerabilities.html.erb +0 -3
  118. data/app/views/solidstats/dashboard/audit/_security_audit.html.erb +0 -14
  119. data/app/views/solidstats/dashboard/audit/_vulnerabilities_table.html.erb +0 -1120
  120. data/app/views/solidstats/dashboard/audit/_vulnerability_details.html.erb +0 -63
  121. data/app/views/solidstats/dashboard/index.html.erb +0 -81
  122. data/app/views/solidstats/gem_metadata/_panel.html.erb +0 -419
  123. data/lib/generators/solidstats/feature/feature_generator.rb +0 -170
  124. data/lib/generators/solidstats/feature/templates/component.html.erb +0 -84
  125. data/lib/generators/solidstats/feature/templates/component.rb.erb +0 -103
  126. data/lib/generators/solidstats/feature/templates/component.scss +0 -243
  127. data/lib/generators/solidstats/feature/templates/component_test.rb.erb +0 -183
  128. data/lib/generators/solidstats/feature/templates/controller.rb.erb +0 -44
  129. data/lib/generators/solidstats/feature/templates/controller_test.rb.erb +0 -111
  130. data/lib/generators/solidstats/feature/templates/detail_view.html.erb +0 -755
  131. data/lib/generators/solidstats/feature/templates/preview.rb.erb +0 -107
  132. data/lib/generators/solidstats/feature/templates/service.rb.erb +0 -132
  133. data/lib/generators/solidstats/feature/templates/service_test.rb.erb +0 -109
  134. data/lib/generators/solidstats/install_generator.rb +0 -109
  135. data/lib/generators/solidstats/templates/initializer.rb +0 -112
  136. data/lib/solidstats/asset_compatibility.rb +0 -238
  137. data/lib/solidstats/asset_manifest.rb +0 -205
  138. data/lib/tasks/solidstats_tasks.rake +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1087b955c118f56234de6e254a1c4f8fbb25184caccae8e72756d277b77d8a4d
4
- data.tar.gz: fd69b3cec25f03c5c2854b76b7ea5fe5154c762a6b22dbe50ef6e423d780aef5
3
+ metadata.gz: dd313b23c968d18619f31b5157b96b2a9c75435398121e800deaf6c2e7d4bfd4
4
+ data.tar.gz: 1f7407373917b47d1ef56ebe7e03138cd36ef111517a930e0c8b6354bc2e389f
5
5
  SHA512:
6
- metadata.gz: 45d75fb7fbbccb543628e14747177807f8fb7b652be35cb74d05a5fe65b666731c4290413ce7e0da2a5038cb9d68c265916bbe2421949b073424eb5b603018ad
7
- data.tar.gz: 8d425d7b2f9abcba38460f5ec97fa0e5021fbc1542e00442c97e7b099707bc4a11d578f53f440fc213885e8172706fa947fd57f025283abfdfe09b93d8a965e6
6
+ metadata.gz: adcd27c59ddc3e68c8843583dd274d96312959155c3a0491f06540cd1eb474681bcb7de407b6d286bc1a9e97dd03b4e94099b3e40f5232a37929b3c2565e1cd2
7
+ data.tar.gz: 515a1510e1911e65f8b7784bf746341112f469de7800170923f3f3f716c537825fe742afa266ecb5fc091ad9c1e3c7aebfbef328eef964da69960a7b0d63506b
data/CHANGELOG.md CHANGED
@@ -5,73 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [2.0.0] - 2025-05-26
8
+ ## [3.0.0] - 2025-06-11
9
9
 
10
10
  ### Added
11
- - **Complete Gem Metadata System**: Comprehensive gem dependency tracking and management
12
- - Dual-view interface with grid and table layouts
13
- - Real-time search and filtering by gem name, status, and other criteria
14
- - Smart sorting by name, status, release date, and version information
15
- - Status indicators for outdated, up-to-date, and unavailable gems
16
- - Dependency visualization with runtime dependency details
17
- - Version comparison showing current vs. latest versions
18
- - CSV export functionality for gem data analysis
19
- - Refresh capability to update gem metadata from RubyGems API
20
- - Responsive design with 3-cards-per-row grid (2 on tablet, 1 on mobile)
21
-
22
- - **View Component Architecture**: Modern component-based UI system for maintainable code
23
- - BaseComponent foundation for all UI components
24
- - Specialized components for different dashboard sections
25
- - Component preview system for development and testing
26
- - Reusable UI components (ActionButton, SummaryCard, Navigation, TabNavigation)
27
- - Clean separation of concerns between HTML, CSS, and JavaScript
28
-
29
- - **Feature Generator System**: Automated development tools for rapid feature development
30
- - `rails g solidstats:feature` generator for creating new dashboard sections
31
- - Automatic component, controller, view, and asset generation
32
- - Built-in best practices and conventions
33
- - Template-based code generation with customizable options
34
-
35
- - **CSS Component Architecture**: Modular styling system with 1,631+ lines of extracted CSS
36
- - Dedicated component stylesheets for maintainable styling
37
- - Conflict-free CSS with proper specificity management
38
- - Responsive design patterns and mobile-first approach
39
- - Consistent design tokens and reusable style patterns
11
+ - **LoadLens Performance Monitor**: A new development performance monitoring feature that parses development logs to track Rails application performance. It includes metrics for response times, database performance, view rendering, and error rates.
12
+ - **Style Patrol**: A new code quality analysis feature to enforce style guidelines and improve code health.
13
+ - **My TODOs Feature**: A new service to manage and track TODO items within the codebase, with a dedicated UI and refresh functionality.
14
+ - **Bundler Audit Security**: Added security auditing for Bundler, with a dedicated UI to display vulnerability details and remediation suggestions.
40
15
 
41
- ### Fixed
42
- - **Gem Metadata Table Layout**: Eliminated horizontal scrolling issues
43
- - Changed table wrapper from `overflow-x: auto` to `width: 100%`
44
- - Removed restrictive `white-space: nowrap` from table headers
45
- - Implemented percentage-based column widths for better responsiveness
46
- - Added proper word-wrapping for long content
47
-
48
- - **Empty State Positioning**: Perfect centering for "No matching gems found" messages
49
- - Implemented flexbox-based centering for both grid and table views
50
- - Added proper fallback support for older browsers
51
- - Enhanced visual hierarchy and user experience
52
-
53
- - **Navigation System**: Fixed section-based navigation throughout the application
54
- - Removed external routing in favor of seamless section switching
55
- - Updated all navigation components to use `data-section` attributes
56
- - Eliminated page reloads when switching between dashboard sections
57
- - Consistent navigation behavior across all components
58
-
59
- - **CSS Conflicts**: Resolved styling conflicts between component stylesheets
60
- - Fixed security.css interference with gem metadata styling
61
- - Implemented proper CSS specificity to prevent style bleeding
62
- - Added scoped styling for component isolation
63
-
64
- ### Improved
65
- - **Performance Optimizations**: Enhanced user experience with better responsiveness
66
- - Debounced search functionality to reduce unnecessary API calls
67
- - Efficient DOM manipulation and rendering
68
- - Optimized CSS delivery and reduced file sizes
69
-
70
- - **Cross-Browser Compatibility**: Enhanced support for different browsers and devices
71
- - Fallback CSS for older browser versions
72
- - Progressive enhancement patterns
73
- - Improved mobile experience and touch interactions
16
+ ### Changed
17
+ - **Dashboard Redesign**: The Solidstats dashboard has been completely redesigned with DaisyUI, providing a modern, consistent, and themeable user interface.
18
+ - **Refactored Services**: The `LogSizeMonitorService` has been refactored for enhanced log management and caching.
19
+ - **Improved Installation**: The installation process has been enhanced with automatic directory creation and `.gitignore` updates.
74
20
 
21
+ ### Fixed
22
+ - Updated route aliases and paths for better consistency across the application.
23
+ - Replaced static dashboard titles with dynamic links for improved navigation.
75
24
 
76
25
  ## [1.1.0] - 2025-05-23
77
26
 
data/README.md CHANGED
@@ -1,39 +1,19 @@
1
1
  Solidstats is a local-only Rails engine that shows your project's health at `/solidstats`. The dashboard provides real-time insights into your application's security, code quality, and development tasks.
2
2
 
3
3
  ## Features
4
-
5
- ### Core Dashboard
6
4
  - Interactive security dashboard with real-time refresh capability
7
5
  - Comprehensive gem vulnerability analysis with severity breakdown
8
6
  - Visual security score rating (A+, B, C) and metrics
9
7
  - Bundler Audit scan with detailed remediation suggestions
10
8
  - Interactive vulnerability details with patched version information
11
9
  - Gem impact analysis showing affected gems by severity
12
-
13
- ### Gem Metadata System
14
- - **Complete Gem Analysis Platform**: Comprehensive gem metadata dashboard with detailed information about all gems in your project
15
- - **Dual-View System**: Switch between table and grid layouts for optimal data presentation
16
- - **Table View**: Sortable columns with gem name, version, description, dependencies, and status
17
- - **Grid View**: Card-based layout with 3 cards per row (responsive: 3 on desktop, 2 on tablet, 1 on mobile)
18
- - **Advanced Filtering**: Real-time search and filtering across all gem attributes
19
- - **Dependency Analysis**: View gem dependencies with version compatibility information
20
- - **Status Monitoring**: Real-time health indicators and gem status tracking
21
- - **Download Statistics**: Popularity metrics and download statistics for gems
22
- - **License Information**: Security compliance and license tracking
23
-
24
- ### System Monitoring
25
10
  - Log Size Monitor for tracking and managing application log files
26
11
  - Log file truncation tool for individual or all log files
12
+ - LoadLens - Development performance monitoring with request tracking
27
13
  - Rubocop offense count and quality metrics
28
14
  - TODO/FIXME tracker with file hotspots
29
15
  - Test coverage summary
30
16
 
31
- ### Architecture
32
- - **View Component Architecture**: Modern, maintainable component-based UI system
33
- - **Feature Generator System**: Automated scaffolding for rapid development
34
- - **CSS Component Architecture**: Organized, conflict-free styling with responsive design
35
- - **Cross-Browser Compatibility**: Enhanced support across modern browsers
36
-
37
17
  ## Compatibility
38
18
 
39
19
  - Ruby 2.7+: Compatible with Rails 6.1 through Rails 7.0
@@ -95,21 +75,35 @@ You can refresh the dashboard data at any time by clicking the "Refresh" button
95
75
  3. Show real-time feedback during the refresh process
96
76
  4. Update the "Last Updated" timestamp
97
77
 
98
- ### Gem Metadata
99
- Comprehensive gem analysis and management platform featuring:
100
- - **Complete Gem Information**: Detailed metadata for all gems in your project including versions, descriptions, dependencies, and status
101
- - **Flexible Views**:
102
- - **Table View**: Sortable table with comprehensive gem information, perfect for detailed analysis
103
- - **Grid View**: Card-based layout showing 3 gems per row with visual appeal and responsive design
104
- - **Advanced Search & Filtering**: Real-time filtering across gem names, descriptions, and dependencies
105
- - **Dependency Analysis**: View and analyze gem dependencies with version information
106
- - **Status Monitoring**: Health indicators and status tracking for all gems
107
- - **Download Metrics**: Popularity statistics and download information
108
- - **License Tracking**: Security compliance and license information for each gem
109
-
110
78
  ### Code Quality
111
79
  Displays code quality metrics, test coverage, and code health indicators.
112
80
 
81
+ ### LoadLens Performance
82
+ Monitors your Rails app's performance in development by parsing `log/development.log`:
83
+ - **Response Times**: Average response time across all requests
84
+ - **Database Performance**: ActiveRecord query timing analysis
85
+ - **View Rendering**: Template rendering performance metrics
86
+ - **Error Tracking**: HTTP status code analysis and error rates
87
+ - **Slow Request Detection**: Identifies requests taking >1000ms
88
+ - **Request History**: Recent request details with timing breakdown
89
+
90
+ LoadLens automatically tracks performance data and provides manual refresh capability. Data is stored in daily rotating JSON files and cleaned up after 7 days.
91
+
92
+ **CLI Commands:**
93
+ ```bash
94
+ # Parse development logs manually
95
+ rake solidstats:load_lens:parse_logs
96
+
97
+ # Refresh performance data
98
+ rake solidstats:load_lens:refresh
99
+
100
+ # View performance summary
101
+ rake solidstats:load_lens:summary
102
+
103
+ # Clean old data files
104
+ rake solidstats:load_lens:clean_old_data
105
+ ```
106
+
113
107
  ### Tasks
114
108
  Shows a breakdown of TODO, FIXME, and HACK annotations found in your codebase, with file hotspots and expandable details.
115
109
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require "bundler/setup"
2
-
3
- load "rails/tasks/statistics.rake"
4
-
5
2
  require "bundler/gem_tasks"
3
+
4
+ # Load solidstats-specific tasks
5
+ Dir[File.join(File.dirname(__FILE__), 'lib', 'tasks', '*.rake')].each { |f| load f }
@@ -10,11 +10,6 @@
10
10
  * files in this directory. Styles in this file should be added after the last require_* statement.
11
11
  * It is generally better to create a new file per style scope.
12
12
  *
13
- *= require_tree ./components
13
+ *= require_tree .
14
14
  *= require_self
15
15
  */
16
-
17
- /* Base Solidstats styles */
18
- .solidstats-dashboard {
19
- font-family: system-ui, -apple-system, sans-serif;
20
- }
@@ -0,0 +1,48 @@
1
+ /* Solidstats Dashboard with DaisyUI */
2
+
3
+ /* Custom animations for dashboard */
4
+ .dashboard-enter {
5
+ animation: fadeInUp 0.6s ease-out;
6
+ }
7
+
8
+ @keyframes fadeInUp {
9
+ from {
10
+ opacity: 0;
11
+ transform: translateY(30px);
12
+ }
13
+ to {
14
+ opacity: 1;
15
+ transform: translateY(0);
16
+ }
17
+ }
18
+
19
+ /* Gradient text for brand */
20
+ .gradient-text {
21
+ background: linear-gradient(135deg, #3b82f6, #8b5cf6);
22
+ -webkit-background-clip: text;
23
+ -webkit-text-fill-color: transparent;
24
+ background-clip: text;
25
+ }
26
+
27
+ /* Light mode improvements */
28
+ [data-theme="light"] .card {
29
+ background-color: #ffffff;
30
+ border: 1px solid #e5e7eb;
31
+ }
32
+
33
+ [data-theme="light"] .card:hover {
34
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
35
+ }
36
+
37
+ [data-theme="light"] .stat-value {
38
+ color: #1f2937;
39
+ }
40
+
41
+ [data-theme="light"] .card-title {
42
+ color: #1f2937;
43
+ }
44
+
45
+ [data-theme="light"] .navbar {
46
+ background-color: #ffffff;
47
+ border-bottom: 1px solid #e5e7eb;
48
+ }
@@ -1,80 +1,99 @@
1
1
  module Solidstats
2
2
  class DashboardController < ApplicationController
3
+ layout 'solidstats/dashboard'
4
+
3
5
  TODO_CACHE_FILE = Rails.root.join("tmp", "solidstats_todos.json")
4
6
  AUDIT_CACHE_HOURS = 12 # Configure how many hours before refreshing
5
7
 
6
- def index
7
- # Use new services for data collection
8
- audit_service = AuditService.new
9
- todo_service = TodoService.new
10
- log_monitor_service = LogSizeMonitorService.new
11
8
 
12
- # Get full data for detailed views
13
- @audit_output = audit_service.fetch
14
- @todo_items = todo_service.fetch
15
- @log_data = log_monitor_service.collect_data
16
- @gems = Solidstats::GemMetadata::FetcherService.call
17
-
18
- # Get summary data for dashboard cards
19
- @audit_summary = audit_service.summary
20
- @todo_summary = todo_service.summary
21
-
22
- # TODO: Refactor these to use services as well
23
- @rubocop_output = "JSON.parse(`rubocop --format json`)"
24
- @coverage = "100"
9
+ def dashboard
10
+ # Load dashboard cards from JSON file
11
+ @dashboard_cards = load_dashboard_cards
12
+ @quick_actions = quick_actions_data
13
+ render 'dashboard'
25
14
  end
26
15
 
27
- # Force refresh all dashboard data
28
16
  def refresh
29
- # Create services
30
- audit_service = AuditService.new
31
- todo_service = TodoService.new
32
- log_monitor_service = LogSizeMonitorService.new
33
-
34
- # Force refresh of data
35
- audit_output = audit_service.fetch(true) # Force refresh
36
- todo_items = todo_service.fetch(true) # Force refresh
37
- log_data = log_monitor_service.collect_data
38
- gem_metadata = GemMetadata::FetcherService.call(nil, true) # Force refresh
39
-
40
- # Get updated summaries
41
- audit_summary = audit_service.summary
42
- todo_summary = todo_service.summary
17
+ # Refresh all services
18
+ Solidstats::LogSizeMonitorService.scan_and_cache
19
+ Solidstats::BundlerAuditService.scan_and_cache
20
+ Solidstats::MyTodoService.collect_todos
21
+ Solidstats::StylePatrolService.refresh_cache
22
+ Solidstats::CoverageCompassService.refresh_cache
23
+ Solidstats::LoadLensService.scan_and_cache
24
+
25
+ redirect_to solidstats_dashboard_path, notice: 'Dashboard data refreshed successfully!'
26
+ end
43
27
 
44
- # Get current time for last updated display
45
- last_updated = Time.now.strftime("%B %d, %Y at %H:%M")
28
+ private
46
29
 
47
- # Return JSON response with refreshed data
48
- render json: {
49
- audit_output: audit_output,
50
- todo_items: todo_items,
51
- audit_summary: audit_summary,
52
- todo_summary: todo_summary,
53
- log_data: log_data,
54
- gem_metadata: gem_metadata,
55
- last_updated: last_updated,
56
- status: "success"
57
- }
58
- rescue StandardError => e
59
- # Return error information
60
- render json: {
61
- status: "error",
62
- message: "Failed to refresh data: #{e.message}"
63
- }, status: :internal_server_error
30
+ def quick_actions_data
31
+ [
32
+ {
33
+ icon: 'refresh-cw',
34
+ label: 'Refresh Data',
35
+ color: 'blue',
36
+ action: 'refresh_dashboard'
37
+ },
38
+ {
39
+ icon: 'settings',
40
+ label: 'Configure',
41
+ color: 'purple',
42
+ action: 'open_settings'
43
+ },
44
+ {
45
+ icon: 'download',
46
+ label: 'Export',
47
+ color: 'green',
48
+ action: 'export_data'
49
+ },
50
+ {
51
+ icon: 'bell',
52
+ label: 'Alerts',
53
+ color: 'orange',
54
+ action: 'view_alerts'
55
+ }
56
+ ]
64
57
  end
65
58
 
66
- def truncate_log
67
- log_monitor_service = LogSizeMonitorService.new
68
- filename = params[:filename]
69
-
70
- # Add .log extension if not included in the filename
71
- if filename.present? && !filename.end_with?(".log")
72
- filename = "#{filename}.log"
59
+ def load_dashboard_cards
60
+ json_file_path = Rails.root.join("solidstats", "summary.json")
61
+
62
+ begin
63
+ # Read and parse the JSON file
64
+ json_data = JSON.parse(File.read(json_file_path))
65
+
66
+ # Transform the JSON data into the format expected by the view
67
+ json_data.map do |name, data|
68
+ {
69
+ name: name,
70
+ icon: data["icon"],
71
+ status: data["status"],
72
+ value: data["value"],
73
+ last_updated: Time.parse(data["last_updated"]),
74
+ url: data["url"],
75
+ badges: data["badges"] || []
76
+ }
77
+ end
78
+ rescue Errno::ENOENT
79
+ Rails.logger.warn("Summary JSON file not found, generating initial data...")
80
+ generate_initial_data
81
+ retry
82
+ rescue JSON::ParserError => e
83
+ Rails.logger.error("Error parsing summary JSON: #{e.message}")
84
+ # Fallback to empty array if JSON is invalid
85
+ []
73
86
  end
87
+ end
74
88
 
75
- result = log_monitor_service.truncate_log(filename)
76
-
77
- render json: result
89
+ def generate_initial_data
90
+ # Force a scan to create initial data if missing
91
+ Solidstats::LogSizeMonitorService.scan_and_cache
92
+ Solidstats::BundlerAuditService.scan_and_cache
93
+ Solidstats::MyTodoService.collect_todos
94
+ Solidstats::StylePatrolService.refresh_cache
95
+ Solidstats::CoverageCompassService.refresh_cache
96
+ Solidstats::DevLogParserService.scan_and_cache
78
97
  end
79
98
  end
80
99
  end
@@ -0,0 +1,72 @@
1
+ module Solidstats
2
+ class LogsController < ApplicationController
3
+ layout 'solidstats/dashboard'
4
+
5
+ def logs_size
6
+ @logs_data = Solidstats::LogSizeMonitorService.get_logs_data
7
+ end
8
+
9
+ def truncate
10
+ filename = params[:filename]
11
+
12
+ # Validate filename presence
13
+ if filename.blank?
14
+ return render json: {
15
+ status: "error",
16
+ message: "Filename is required"
17
+ }, status: :bad_request
18
+ end
19
+
20
+ # Remove any path traversal attempts for security
21
+ filename = File.basename(filename)
22
+
23
+ # Ensure it's a .log file
24
+ unless filename.end_with?('.log')
25
+ filename = "#{filename}.log" if filename.present?
26
+ end
27
+
28
+ # Additional security check
29
+ unless filename.end_with?('.log')
30
+ return render json: {
31
+ status: "error",
32
+ message: "Invalid file type. Only .log files can be truncated."
33
+ }, status: :bad_request
34
+ end
35
+
36
+ result = Solidstats::LogSizeMonitorService.truncate_log(filename)
37
+
38
+ if result[:status] == "success"
39
+ render json: {
40
+ status: "success",
41
+ message: result[:message] || "Log file truncated successfully",
42
+ filename: filename,
43
+ original_size: result[:original_size]
44
+ }
45
+ else
46
+ render json: result, status: :unprocessable_entity
47
+ end
48
+ rescue StandardError => e
49
+ Rails.logger.error("Failed to truncate log #{filename}: #{e.message}")
50
+ render json: {
51
+ status: "error",
52
+ message: "Failed to truncate log: #{e.message}"
53
+ }, status: :internal_server_error
54
+ end
55
+
56
+ def refresh
57
+ # Force refresh of log monitoring data
58
+ result = Solidstats::LogSizeMonitorService.scan_and_cache
59
+
60
+ render json: {
61
+ status: "success",
62
+ message: "Log data refreshed",
63
+ data: result
64
+ }
65
+ rescue StandardError => e
66
+ render json: {
67
+ status: "error",
68
+ message: "Failed to refresh log data: #{e.message}"
69
+ }, status: :internal_server_error
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solidstats
4
+ class PerformanceController < ApplicationController
5
+ layout 'solidstats/dashboard'
6
+
7
+ def load_lens
8
+ @performance_data = LoadLensService.get_performance_data
9
+ @metrics = @performance_data[:summary] || {}
10
+ @recent_requests = @performance_data[:recent_requests] || []
11
+ end
12
+
13
+ def refresh
14
+ # Parse new log entries and refresh cache
15
+ parse_result = LoadLensService.parse_log_and_save
16
+ LoadLensService.refresh_data
17
+
18
+ if parse_result[:success]
19
+ redirect_to load_lens_performance_index_path, notice: "LoadLens data refreshed! Parsed #{parse_result[:processed]} new requests."
20
+ else
21
+ redirect_to load_lens_performance_index_path, alert: "Failed to parse logs: #{parse_result[:error]}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solidstats
4
+ class ProductivityController < ApplicationController
5
+ layout 'solidstats/dashboard'
6
+
7
+ def my_todos
8
+ @todos = MyTodoService.collect_todos
9
+ @summary = MyTodoService.get_summary
10
+
11
+ # Group todos by type for display
12
+ @todos_by_type = @todos.group_by { |todo| todo[:type] }
13
+
14
+ # Recent todos (first 10 for quick view)
15
+ @recent_todos = @todos.first(10)
16
+
17
+ # Stats for dashboard
18
+ @stats = {
19
+ total: @todos.length,
20
+ by_type: @todos_by_type.transform_values(&:count),
21
+ files_with_todos: @todos.map { |t| t[:file] }.uniq.length
22
+ }
23
+
24
+ respond_to do |format|
25
+ format.html
26
+ format.json { render json: { todos: @todos, summary: @summary, stats: @stats } }
27
+ end
28
+ end
29
+
30
+ def refresh_todos
31
+ @todos = MyTodoService.collect_todos(force_refresh: true)
32
+
33
+ respond_to do |format|
34
+ format.html { redirect_to my_todos_productivity_index_path, notice: 'TODOs refreshed successfully!' }
35
+ format.json { render json: { status: 'success', message: 'TODOs refreshed', count: @todos.length } }
36
+ end
37
+ end
38
+ end
39
+ end